RE: [xsl] concatenated key

Subject: RE: [xsl] concatenated key
From: "I-Lin Kuo" <ikuoikuo@xxxxxxxxxxx>
Date: Wed, 23 Apr 2003 11:43:49 +0000
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: [xsl] 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