|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Problem with Sorting Elements When using "document
At 2003-12-03 14:46 +0000, Dominic Lisi wrote:
i have this problem, when i try to sort elements which are comming from external files. Sorting works on the current node list, so you must divine an expression in which all of the nodes to be sorted are selected *at one time* into the current node list. i have a masterfile.xml which contains multiple tags like the following: Not a problem with the above, except that your stylesheet approach you described did not consider the current node list. Also, you are resolving your relative URI values in the document() function relative to your stylesheet, and I'm guessing you want them resolved relative to your data, so I changed that as well. Try the following: <xsl:template match="/">
<alpha-list>
<xsl:apply-templates select="document( list/taxpayer/@file, . )/
taxpayer">
<xsl:sort select="name"/>
</xsl:apply-templates/>
</alpha-list>
</xsl:template>The above will push all of your individual taxpayer nodes in sorted order by the text value of the name node (the concatenation of its descendent text nodes ... that's what you implied by your post). The reason this works is that the document function will return the root nodes of *all* of the documents addressed by *each* of the nodes passed in the first argument, thus supplying you with a single current node list with all the nodes to be sorted. I hope this helps. ............................... Ken -- Next public European delivery: 3-day XSLT/2-day XSL-FO 2004-01-?? Instructor-led on-site corporate, government & user group training for XSLT and XSL-FO world-wide: please contact us for the details G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-11-X Practical Formatting Using XSL-FO Member of the XML Guild of Practitioners: http://XMLGuild.info Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








