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

RE: concatenated key

Subject: RE: concatenated key
From: "I-Lin Kuo" <ikuoikuo@xxxxxxxxxxx>
Date: Wed, 23 Apr 2003 11:43:49 +0000
xslt join node value
Thanks, David. Although I haven't looked into xslt 2, the code is understandable, and it looks like it will do what I want, with the modification of

<xsl:if test="some $x in //node/@name satisfies ($x =
$theseChildren)">

because I'm not limited to searching among nodes at the same level. I'll keep that in mind for when xslt 2 is more widely supported.

I'm still looking for a key-based solution, however, as I'll be doing this lookup a lot and I don't want to search the entire tree every time. Does xslt 2 have a concat() function which takes a node-set and then joins everything together? I'd like to do something like concat(node/@name). Better yet, I'd like to see a function join(node-set, delimiter) which can be used to produce delimited lists...

I-Lin Kuo, Ann Arbor, MI
Macromedia Certified ColdFusion 5.0 Advanced Developer
Sun Certified Java 2 Programmer
Ann Arbor Java Users Group (http://www.aajug.org)





----Original Message Follows----
From: David.Pawson@xxxxxxxxxxx
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  concatenated key
Date: Wed, 23 Apr 2003 09:06:42 +0100


> Given a node, I'm trying to identify/pull out those nodes in > the document > having the same set of identically named child nodes. For > example, given the > node Alpha in the following, I'd like to pull out the "Alpha2" node. > > <node name="Alpha"> > <node name="a"/> > <node name="b"/> > </node> > <node name="roman"> > <node name="i"/> > <node name="ii"/> > </node> > <node name="Alpha2"> > <node name="a"/> > <node name="b"/> > </node>

Beating Jeni to it for once :-)
In xslt 2 this is




<xsl:template match="node"> <xsl:variable name="theseChildren" select="node/@name"/> <xsl:if test="some $x in ../node/node/@name satisfies ($x = $theseChildren)"> <xsl:variable name="this" select="generate-id()"/> (I am <xsl:value-of select="@name"/>) <xsl:for-each select="../node"> <xsl:if test="(node/@name = $theseChildren ) and not(generate-id() = $this)"> Match at <xsl:value-of select="position()"/> <br />

      </xsl:if>
  </xsl:for-each>
</xsl:if>
</xsl:template>


HTH DaveP



_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail



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.