As an alternative view, you often get simpler and more maintainable
stylesheets by doing the processing in stages using multiple stylesheets.
In particular, I often find it useful to have a phase that augments the
original document with extra information, and then a processing phase.
To apply that principle here, you would have one stylesheet that augments
the original file with dates to produce
<list>
<file date="...">file1.xml</file>
<file date="...">file2.xml</file>
...
<file date="...">file100.xml</file>
<list>
and then you would use a second stylesheet to do the sorting (and strip
out the extra "date" attributes as preferred). Now, for this particular
example, the "all in one stylesheet" approach isn't too bad, but I would
often use two stylesheets anyway, just for ease of debugging and
maintenance.
Cheers, Tony.
On Tue, 15 May 2007 13:41:55 +0100, Vaduvoiu Tiberiu
<vaduvoiutibi(_at_)yahoo(_dot_)com> wrote:
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 document will list the dates but it doesn't sort them.
I also tried <xsl:sort order="descending" data-type="number"
select="document($filename)/date"> but it doesn't work. It sorts the
list alphabetically after the name of file...file1,file2...file100. What
am I doing wrong? 10x
--
Anthony B. Coates
Senior Partner
Miley Watts
Experts In Data
+44 (79) 0543 9026
Data standards participant: ISO 20022 (ISO 15022 XML), ISO 19312,
UN/CEFACT TMG, MDDL, FpML, UBL.
--~------------------------------------------------------------------
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>
--~--