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

Subject: RE: [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 14:36:10 +0100
Unfortunately I have no control over the XML that I need to apply the
stylesheet to.

All that is required of the output is that the values are displayed in
the correct rows (i.e. matching the occurences).

They display correctly when I create the same number of /option elements
for each option list.

Unfortunately the problem is, as I said that I'm not in control of the
XML to process.

-----Original Message-----
From: cknell@xxxxxxxxxx [mailto:cknell@xxxxxxxxxx]
Sent: 09 March 2006 03:19 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] FW: XSL processes XML incorrectly when uneven number
of values returned in array elements

Tsk, tsk, tsk.

1) The data document isn't well-formed.

<optionList1>
 <option>1</option>
 <option>2</option>
</List1>

Note the opening tag doesn't match the closing tag, therefor this isn't
XML.
Now, correcting this, I moved on to the XSLT and found that what it's
trying to output isn't HTML:

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

Note the closing </a> doesn't have a matching opener (<a>).

Now how about an example output of what you want to get from the
transformation, or at least, tell us whether each <optionListx> should
produce a row in the output or should it produce a column in which case
the <option> elements with matching positions relative to it's siblings
make up the successive <td> elements in the output. (This last sentence
is why I recommend example output rather than descriptions of the
desired output.)

And here's another piece of advice. If you have any control over the XML
format, immediately kill the idea that each <optionListx> element should
have a unique name. If you need to differentiate them, use an attribute.
So ...

<optionList1> becomes <optionList id="1"> <optionList2> becomes
<optionList id="2"> <optionList3> becomes <optionList id="3">

This will make writing and maintaining a stylesheet much easier.

--
Charles Knell
cknell@xxxxxxxxxx - email

Current Thread