xsl-list
[Top] [All Lists]

RE: Sorting on a transformed string?

2002-10-26 10:29:24
Hi,

can you change the XML? YOu could do it pretty easily if the structure was
something like:

<Member name="System">
   <Member name="Caption">
      <Member name="Insert">

      </Member>
   </Member>
   <Member name="Collections">
      <Member name="ICollection">
         <Member name="Count">

         </Member>
      </Member>
   </Member>
</Member>


-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com]On Behalf Of 
Scott Bronson
Sent: Saturday, October 26, 2002 9:58 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Sorting on a transformed string?


Hello.  A sort problem is stumping me right now.  I've got the following
nodes:

    <Member name="CreateInstance">
    <Member name="System.Caption.Insert">
    <Member name="System.Collections.ICollection.Count"

I'd like to sort them by name, without leading namespace:

    Count, CreateInstance, Insert

Then I'd like to output them, WITH the namespace:

    System.Collections.ICollection.Count
    CreateInstance
    System.Caption.Insert

Normally, I use leaf-name (below) to trim the namespace.  However, I
suspect it's impossible to get sort to use a named template, and I
haven't figured out any other way of figuring out the leaf name.

Is possible to sort on the leaf name?  Is it possible in XML 1.0?  :)

Thank you!

    - Scott



<xsl:template name="leaf-name">
  <xsl:param name="string"/>
  <xsl:choose>
    <xsl:when test="substring-after($string,'.')">
      <xsl:call-template name="leaf-name">
        <xsl:with-param name="string"
select="substring-after($string,'.')"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$string"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>