Reputation: 13
I am attempting to pull out some values and display an array of arrays in Excel dynamically. However, my nested for-each doesn't and I receive no output no matter what I try. I have, of course, left out some stuff within the sheet
and data
, so right now they seem as if they're unnecessarily nested, but that isn't the case.
XML:
<report>
<sheet>
<data>
<table>
<row>
<column value="Germany" />
<column value="Berlin" />
<column value="2321341" />
</row>
<row>
<column value="USA" />
<column value="Washington DC" />
<column value="11111" />
</row>
</table>
</data>
</sheet>
</report>
The XSL nested for-each I try to get to work. It works when I remove the inner for-each and try displaying the first value by doing <xsl:value-of select="column/@value">
, so it creates two new rows, each containing the name of the country (which is the first element of the column list).
<xsl:for-each select="report/sheet/data/table/row">
<ss:Row>
<xsl:for-each select="row/columm">
<ss:Cell>
<ss:Data ss:Type="String">
<xsl:value-of select="@value" />
</ss:Data>
</ss:Cell>
</xsl:for-each>
</ss:Row>
</xsl:for-each>
Upvotes: 1
Views: 87
Reputation: 116993
First, you have a typo in:
<xsl:for-each select="row/columm">
The name of the element is column
, not columm
.
More importantly, the instruction:
<xsl:for-each select="report/sheet/data/table/row">
puts you in the context of row
. From this context,
<xsl:for-each select="row/column">
selects nothing, because row
is not a child of itself. It needs to be:
<xsl:for-each select="column">
Upvotes: 1