Subject: Re: [xsl] sort elements in external document From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Tue, 15 May 2007 13:53:00 +0100 |
I want to sort an xml document by data from an external document. Let me see if I can explain this: I have list.xml:
<list> <file>file1.xml</file> <file>file2.xml</file> ... <file>file100.xml</file> <list>
each of the fileX.xml have inside a date tag: <date>20071015102000</date>(yyyymmddhhmmss). I want to sort the list.xml by the date in each file. The way I did it: <xsl:for-each select="file"> <xsl:variable name="filename" select="file"/> <xsl:sort order="descending" select="document($filename)/date">
File: <xsl:value-of select="."> Date: <xsl:value-of select="document($filename)/date"> </xsl:for-each>
The variable $filename is selecting the child <file> of the <file> element selected by the for-each, which doesn't exist so the sort value is empty each time. So change
<xsl:for-each select="document(file)"> <xsl:sort select="/path/to/date"/> ....
as then the context node is the root of the document referenced by document() and not the <file> element in the list.
cheers andrew
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] sort elements in external, David Carlisle | Thread | Re: [xsl] sort elements in external, Anthony B. Coates (X |
Re: [xsl] sort elements in external, David Carlisle | Date | Re: [xsl] sort elements in external, Florent Georges |
Month |