[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Three questions on sorting..
Hi Tim, > Got sorting by a varibale going, easy with Mike's example. I've had > a good look throught the FAQ's again but nothing similar to the sort > by external elements. I copied Mike's other example and changed it a > bit: > > ......snip...... > <xsl:variable name="manExt" select="document('manufacturers.xml')"/> > .................. > <xsl:when test="$orderBy='manufacturer'"> > <xsl:for-each select="car"> > <xsl:variable name="manId"><xsl:value-of select="normalize-space > (manufacturer)"/></xsl:variable> > <xsl:sort select="$manExt/manufacturers/manufacturer > [@ID=$manId]/name"/> [snip] The xsl:sort has to be the first child of the xsl:for-each - you can't set a variable before it. However, you can access the manufacturer of the car that you want to sort using the current() function to get the current node (the node that the XSLT is processing rather than the node that you're looking at within the XPath). So try: <xsl:for-each select="car"> <xsl:sort select="$manExt/manufacturers /manufacturer[@ID = current()/manufacturer] /name" /> ... </xsl:for-each> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ 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
|