[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Is it possible to sort the way I want
I am building a flat table from the contents of a hierarchical XML tree. I want to sort on the fully qualified name of the element but the data does not have a qname attribute. Is it possible? For example the data might look like this (a representation of Java code perhaps): <package name="serviceb"> <package name="subpackageofb"> </pacakge> <package name="anothersubpackagetofb"> </pacakge> </pacakge> <package name="servicea"> <package name="subpackageofa"> <package name="subsubpackageofa"> </pacakge> </pacakge> <package name="anothersubpacakgeofa"> </pacakge> </pacakge> <package name="servicec"> </pacakge> and I want the flat list to look like this: serviceA serviceA.anothersubpackageofa serviceA.subpackageofa serviceA.subpackageofa.subsubpackageofa serviceB serivceB.anothersubpackageofa serviceB.subpackageofa serivceC when I process this using: <xsl:for-each select="//package"> <xsl:sort select="@name"/> stuff to build the table... I get this as my order serviceA serviceB serivceC serivceB.anothersubpackageofa serviceA.anothersubpackageofa serviceA.subpackageofa.subsubpackageofa serviceB.subpackageofa serviceA.subpackageofa which is as expected since it is sorting on just the name of the package. I also tried this: <xsl:for-each select="//package"> <xsl:sort select="ancestor-or-self::*/@name"/> but that seemed to give me document order or at least not what I want. Can this be done directly? Can I derive the fully qualified name using XPath for use in the select of the sort element? I have a template that outputs the fully qualified name but it will not 'fit' in a select statement. Or am I forced to insert the qualified name into the XML? Any advice would be appricated. Thanks, IL __________________________________ Do you Yahoo!? Yahoo! Small Business $15K Web Design Giveaway http://promotions.yahoo.com/design_giveaway/
|
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
|