xsl-list
[Top] [All Lists]

Re: [xsl] How Can I Reference previous XML in Subsequent Iterations?

2007-04-18 09:24:56
Chris M. wrote:
Well, here we have a node-set, not the layout in the original XML. In this case, it is the same, and crucial to the output.

I found out the hard way that a sorted node-set is not iterated in the sorted order, but the order in the original predicate. I am also limited to using XPath 1.0 (the libxslt implementation used in PHP 5), so I miss out on some very nice XPath 2.0 functions).


No, you are not limited to XPath/XSLT 1.0. With PHP you can call anything from outside that language. Actually, that is what you are already doing (libxslt is written in C++, not in PHP). You can choose to use Saxon 8.9 or Gestalt, the first is in .NET and Java, the latter in Eiffel, but both can be called from PHP with only a little trouble.

Though your current problem is fairly easily solvable by XSLT 1.0 alone (but you may quickly find it limited if you start to use if more).

Everything, both in XSLT 1.0 and 2.0 is "iterated" in document order. If you want to sort something, you can do so in XSLT with the xsl:sort instruction (which sorts the result, not the input). Of course you can sort the content of your document before it gets to XSLT, but if all you need is to sort the output, you can stick to XSLT alone. As a matter of fact, I have never seen a use case where I needed the order of the input different than the document order. Focus on the output, not the input (it is a declarative language, remember).

Cheers,
-- Abel

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--