xsl-list
[Top] [All Lists]

Re: [xsl] sort elements in external document

2007-05-15 05:52:45

<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. 
________________________________________________________________________

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>