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: cknell@xxxxxxxxxx
Date: Thu, 09 Mar 2006 08:18:42 -0500
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