[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Is it possible to sort the way I want
Subject: [xsl] Is it possible to sort the way I want From: Ian Lang <ianplang@xxxxxxxxx> Date: Thu, 8 Apr 2004 22:58:25 -0700 (PDT) |
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/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Grouping and Key Problem, Mukul Gandhi | Thread | RE: [xsl] Is it possible to sort th, Michael Kay |
[xsl] Grouping and Key Problem, James Hunt | Date | RE: [xsl] match all attributes exce, Michael Kay |
Month |