- <xsl:stylesheet version ="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
- <xsl:output method ="html" />
- <xsl:template match ="/" >
- <ROOT>
- <xsl:call-template name="texttorows" >
- <xsl:with-param name="StringToTransform" select="/ROOT" />
- <xsl:with-param name="RowNum" select="0"/>
- </xsl:call-template>
- </ROOT>
- </xsl:template>
- <xsl:template name ="texttorows" >
- <xsl:param name ="StringToTransform" select ="''" />
- <xsl:param name ="RowNum" select ="0" />
- <xsl:choose>
- <xsl:when test ="contains($StringToTransform,'
')" >
- <xsl:variable name="stringlen"><xsl:value-of select="string-length(substring-before($StringToTransform,'
'))"/>
- </xsl:variable>
- <xsl:if test="$stringlen > 1">
- <ROW>
- <xsl:attribute name="RowNum"><xsl:value-of select="$RowNum"/></xsl:attribute>
- <xsl:call-template name ="csvtoxml" >
- <xsl:with-param name ="StringToTransform" select ="substring-before($StringToTransform,'
')" />
- </xsl:call-template>
- </ROW>
- </xsl:if>
- <xsl:call-template name ="texttorows" >
- <xsl:with-param name ="StringToTransform" >
- <xsl:value-of select ="substring-after($StringToTransform,'
')" />
- </xsl:with-param>
- <xsl:with-param name ="RowNum" select="$RowNum + 1"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name ="csvtoxml" >
- <xsl:param name ="StringToTransform" select ="''" />
- <xsl:param name ="FieldNum" select ="1" />
- <xsl:choose>
- <xsl:when test ="contains($StringToTransform,'|')" >
- <xsl:choose>
- <xsl:when test ="$FieldNum = 1">
- <NAME>
- <xsl:value-of select ="substring-before($StringToTransform,'|')" />
- </NAME>
- </xsl:when>
- <xsl:when test ="$FieldNum = 2">
- <SOMEVALUE>
- <xsl:value-of select ="substring-before($StringToTransform,'|')" />
- </SOMEVALUE>
- </xsl:when>
- <xsl:when test ="$FieldNum = 3">
- <SOMECODE>
- <xsl:value-of select ="substring-before($StringToTransform,'|')" />
- </SOMECODE>
- </xsl:when>
- <xsl:otherwise>
- <SOMEDATE>
- <xsl:value-of select ="substring-before($StringToTransform,'|')" />
- </SOMEDATE>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:call-template name ="csvtoxml" >
- <xsl:with-param name ="StringToTransform" >
- <xsl:value-of select ="substring-after($StringToTransform,'|')" />
- </xsl:with-param>
- <xsl:with-param name ="FieldNum" select="$FieldNum + 1"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </xsl:stylesheet>
hola a todos
Tengo un fichero formato .dat los datos me vienen de la siguiente forma: Lo abro con el programa de bloc de notas.
2009|12|4|12/09/2009|4453|T|1|34880|010,41|33365 21687 21690 84776|E6132DSH|1|
Entre cada barra es un campo pero cuando quiero importar el fichero me lo lleva toda la linea a un campo hasta la coma despues de la coma me lo lleva a la siguiente campo, pero yo quiero los datos entre las barras se lleve a un campo
ej.
2009 a un campo llamado año
12 a un campo llamado mes
4 a un campo llamado dia
12/9/2009 a un campo llamado fecha
etc.
¿como puedo hacer los pasos para conseguir los resultaos que he dicho anteriormente?
Muchas Gracias, un saludo a todos.






