Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Insert a CRLF when transforming XML into text Insert a CRLF when transforming XML into textTo: NULL Date: 1/3/2009 4:40:00 PM 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?
The XML file I use, depicts master and detail records. In the CSV, I want to
have each of the master record and its detail records in one line, no matter
how many detail records there are for each master. Master fields are
separated by semicolon (;) and the details are separated by caret sign (^).
XML follows:
<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
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
