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="1.0"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = " <xsl
utput method="text"/>
<xsl:template match="/">
<xsl:variable name="newline"> <xsl:text> </xsl:text> </xsl:variable>
<xsl:for-each select="rrd/ds">
<xsl:value-of select="normalize-space(name)"/><xsl:value-of select="$newline"/>
<xsl:for-each select="../rra/database/row">
<xsl:value-of select="v"/>,
</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.
<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="1.0"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = " <xsl
<xsl:template match="/">
<xsl:variable name="newline"> <xsl:text> </xsl:text> </xsl:variable>
<xsl:for-each select="rrd/ds">
<xsl:value-of select="normalize-space(name)"/><xsl:value-of select="$newline"/>
<xsl:for-each select="../rra/database/row">
<xsl:value-of select="v"/>,
</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.