[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] FW: XSL processes XML incorrectly when uneven number of values returned in array elements


Subject: [xsl] FW: XSL processes XML incorrectly when uneven number of values returned in array elements
From: "Cave, Neil" <Neil.Cave@xxxxxxxxxxxxxx>
Date: Thu, 9 Mar 2006 13:34:44 +0100

Hello XSL ninjas

I have been struggling with some XSL processing that reads an XML
document with an inconsistent number of array (list)values that need to
be processed into a table.

I have an stylesheet that processes an XML document that looks something
like this...

<enquiry-data>
<free-xml>
<optionList1>
 <option>1</option>
 <option>2</option>
</List1>
<optionList2>
<option>d</option>
 <option>e</option>
 <option>f</option>
</optionList2>
<optionList3>
<option>X</option>
</optionList3>
</free-xml>
</enquiry-data>

The XSL processing into an HTML table looks like this...

<td>

<xsl:for-each select="//enquiry-data/free-xml/optionList1/*">
<xsl:value-of select="."/></a><br/>
</xsl:for-each>
</td>

<td>
<xsl:for-each select="//enquiry-data/free-xml/optionList2/*">
<xsl:value-of select="."/></a><br/>
</xsl:for-each>
</td>

<td>
<xsl:for-each select="//enquiry-data/free-xml/optionList3/*">
 <xsl:value-of select="."/></a><br/>
</xsl:for-each>
</td>

The problem is that because the XML returns a different amount of array
values (i.e 2 values in optionList1, 3 in 2 and 1 in 3) The XSL displays
the resulkts incorrectly.

What I means is that if the for:each statement for optionList1 displays
the value for 1 from optionList1/option[0] in row 2 or 3 instead of
displaying it in the frirst row.

How do I ensure that the XSL will display each occurence on the correct
table row?

I am new to the list and did not want to attach the actual XML and XSL

Regards
Neil


Current Thread
Keywords