Subject: Re: [xsl] sort elements in external document From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 15 May 2007 13:52:25 +0100 |
<xsl:for-each select="file"> that iterates over all the file elements <xsl:variable name="filename" select="file"/> that selects the file element child of the current node (which is the file element) in your example this is empty in all cases. you want <xsl:variable name="filename" select="."/> <xsl:sort order="descending" select="document($filename)/date"> xsl:sort has to be the first child of xsl:for-each you could you want <xsl:for-each select="document(file)"> <xsl:sort select="date"/> <xsl:value-of select="date"/> </xsl:for-each> but that just gives the date (this assumes based on your example xpath <xsl:value-of select="document($filename)/date"> that file1.xml _only_ has a single date element in xslt2 if you also weant the filename you could change that to <xsl:for-each select="document(file)"> <xsl:sort select="date"/> <xsl:value-of select="base-uri(),date"/> </xsl:for-each> But in xslt1 if you want the names you need to save them before you move into the file: <xsl:for-each select="file"> <xsl:sort select="document(file)/date"/> <xsl:value-of select="."/> <xsl:text> </xsl:text> <xsl:value-of select="document(file)/date"/> </xsl:for-each> David ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] sort elements in external doc, Vaduvoiu Tiberiu | Thread | Re: [xsl] sort elements in external, Florent Georges |
[xsl] sort elements in external doc, Vaduvoiu Tiberiu | Date | Re: [xsl] sort elements in external, Andrew Welch |
Month |