[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Getting a distinct list of node names

Subject: RE: Getting a distinct list of node names
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Mon, 15 Dec 2003 21:04:50 +0100
xsl distinct list
> -----Original Message-----
> From: Manuel Holtgrewe
>
> I need to get a distinct list of the node names from all children of one
> node. For example, if I have:
>
>     <node:definition>
>         <form:validator />
>         <form:validator />
>         <form:filter />
>     </node:definition>
>

tricky one...

I tried it like:

<xsl:template match="node:definition">

  <xsl:for-each select="*[name(.) != preceding::*]">
    <xsl:if test="position() = 1">
      <xsl:text>('</xsl:text>
    </xsl:if>
    <xsl:value-of select="name()" />
    <xsl:text>'</xsl:text>
    <xsl:choose>
      <xsl:when test="position() != last()">
        <xsl:text>, </xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>)</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>

</xsl:template>

Provided you include the namespace declaration for the node:* namespace in
your XSL, there shouldn't be any problems... Could get expensive with long
lists maybe.


Cheers,

Andreas


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.