Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have the following formatt of xml

Status
Not open for further replies.

cdon

Programmer
Jul 5, 2003
17
GB
I have the following formatt of xml document which was supplied to me.

<rrd>
....
<ds>
<name> AVAIL </name>
....
</ds>
<ds>
<name> OUTOCTETS </name>
....
</ds>
...
<rra>
<datbase>
<rows><v>...</v><v>...</v><v>...</v>.......</rows>
<rows><v>...</v><v>...</v><v>...</v>.......</rows>
...
</database>
</raa>
</rrd>

I want to produce CSVs with each ds name followed by the corresponding column in the database ie AVAIL with v column1,OUTOCTETS with v column 2 ect

The code I have at the moment will produce CSV but each ds name is followed by the first v column data.

<?xml version=&quot;1.0&quot;?>
<xsl:stylesheet version = &quot;1.0&quot; xmlns:xsl = &quot; <xsl:eek:utput method=&quot;text&quot;/>
<xsl:template match=&quot;/&quot;>
<xsl:variable name=&quot;newline&quot;> <xsl:text> </xsl:text> </xsl:variable>
<xsl:for-each select=&quot;rrd/ds&quot;>
<xsl:value-of select=&quot;normalize-space(name)&quot;/><xsl:value-of select=&quot;$newline&quot;/>
<xsl:for-each select=&quot;../rra/database/row&quot;>
<xsl:value-of select=&quot;v&quot;/>,
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

I also cannot get my new line to work either. It keeps being replaced by a space. I have tried <br/>,
<xsl:text>
</xsl:text> and & # 10; (without spaces) to no avail.

Any suggestions about either problem would be greatly appreciated as I have little idea how to solve them.
 
I have solved my first problem but still can't get the new line to work.
 
When using <xsl:eek:utput method=&quot;text&quot;/> use & # 1 3 ; (remove spaces between & and ;) for a carriage return (or new line)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top