xslt - xml transformation via xsl (msxsl) -


i need convert xml-file csv-file. therefore i'm using msxsl. xml-file looks this:

(...) <test>   <field1>blabla</field1>   <values>     <year>2012</year>      <value>12</value>   </values>   <values>     <year>2013</year>      <value>1234</value>   </values>   <field2>abc</field2> </test>  <test>   <field1>blubblub</field1>   <field2>def</field2> </test> (...) 

which means: there data sets "test" several nodes "values", , others without any.

i tried solve for-each:

(...) <xsl:for-each select="test"> (...) <xsl:for-each select="values"> (...) </xsl:for-each> </xsl:for-each> (...) 

this works (in way), number of colums not match between data sets. need have in every data set maximum number of colums every node in whole file.

in end 1 should able open csv-file excel. therefore each column need contain same data... there way this?

thanks!

edit: in case expected csv-output this:

blabla;2012;12;2013;1234;abc blubblub;;;;;def 

... , not:

blabla;2012;12;2013;1234;abc blubblub;def 

given expected csv output (actually ssv, semicolon-separated-values, seems), don't think want inner for-each @ all. more along lines of:

<xsl:for-each select="test">     <xsl:value-of select="field1"/>     <xsl:text>;</xsl:text>     <xsl:value-of select="values[1]/year"/>     <xsl:text>;</xsl:text>     <xsl:value-of select="values[1]/value"/>     <xsl:text>;</xsl:text>     <xsl:value-of select="values[2]/year"/>     <xsl:text>;</xsl:text>     <xsl:value-of select="values[2]/value"/>     <xsl:text>;</xsl:text>      <!-- etc, final... -->      <xsl:value-of select="field2"/> </xsl:for-each> 

this gives fixed number of fields, empty values no node exists.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -