<Section> <!-- master 1-->
<BetStartDate>4/6/2009</BetStartDate>
<BetEndDate>4/8/2009</BetEndDate>
<Event> <!-- details -->
<Code>111</Code>
<Description>TEAM 1</Description>
<Apodosi>10,00</Apodosi>
</Event>
<Event>
<Code>112</Code>
<Description>TEAM 2 </Description>
<Apodosi>20,00</Apodosi>
</Event>
</Section>
<Section> <!-- master 2-->
<BetStartDate>12/12/2008</BetStartDate>
<BetEndDate>16/12/2008</BetEndDate>
<Event> <!-- details -->
<Code>211</Code>
<Description>TEAM 3</Description>
<Apodosi>5,00</Apodosi>
</Event>
<Event>
<Code>212</Code>
<Description>TEAM 4</Description>
<Apodosi>4,00</Apodosi>
</Event>
<Event>
<Code>213</Code>
<Description>TEAM 5</Description>
<Apodosi>7,00</Apodosi>
</Event>
</Section>
I want to get:
4/6/2009;4/8/2009^111^TEAM 1^10,00^112^TEAM 2^20,00
12/12/2008;16/12/2008^211^TEAM 3^5,00^212^TEAM 4^4,00^213^TEAM 5^7,00
I use the following template, which works, except it outputs only one line
that includes everything. I want to have a CRLF after 20,00 as displayed
above.
<xsl:template match="/">
<xsl:for-each select="Section">
<xsl:value-of select="BetStartDate" />;<xsl:value-of
select="BetEndDate"/><xsl:for-each select="Event">^<xsl:value-of
select="Code"/>^<xsl:value-of select="Description"/>^<xsl:value-of
select="Apodosi"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
TIA
>I want to create a CSV (text) file out of a XML file, so it can be bulk
>copied into SQLServer. How can I insert a CRLF char when I'm done converting
>every record into its corresponding CSV?
You need to add the character entity corresponding to a newline /
carriage return after each output group (inside your xsl:for-each) :
<xsl:text> </xsl:text>
Note the snippet you provided should probably have a line after
xsl:stylesheet and before xsl:template reading
<xsl:output method="text" .... />
HTH
Cheers - Neil
------------------------------------------------
Digital Media MVP : 2004-2009
http://mvp.support.microsoft.com/mvpfaqs
TIA
OK so far you haven't shown your stylesheet - the suggestion for
character entities was to clearly indicate where the intended CR/LF
should appear, rather than using the invisible <press enter> method.
Perhaps http://www.xml.com/pub/a/2001/12/05/whitespace.html and other
google searches on white space in XSL might be more useful - note how
they squash the space within the XSL stylesheet to get the desired
output.
Although it might not look readable to you, the machine will have no
problem processing that even if all the xsl: instructions are squashed
together into a single line.