Hi Karsten,

     A node-set is truly a set of nodes, so the union of two node-sets 
will contain only unique nodes.  You could write either of the following, 
depending on how early you want to get the single node set.

<xsl:variable name="nodes1and2"
              select="key('element_index', $id1)|
                      key('element_index', $id2)"/>

or

<xsl:variable name="nodes1and2" select="$node1|$node2"/>


     If you happen to have another variable (say, idns) whose value is a 
node-set that contains nodes whose values when converted to strings are 
equal to $id1 and $id2, you could also write the following.

<xsl:variable name="nodes1and2"
              select="key('element_index', $idns)"/>

Thanks,

Henry
------------------------------------------------------------------
Henry Zongaro      Xalan development
IBM SWS Toronto Lab   Tie Line 969-6044;  Phone (905) 413-6044
mailto:[EMAIL PROTECTED]




"Karsten Theis" <[EMAIL PROTECTED]>
02/28/2003 04:24 AM
Please respond to karsten.theis

 
        To:     "XALAN Mailing List (E-Mail)" <[EMAIL PROTECTED]>
        cc: 
        Subject:        Unique merging of node-sets

 

Hi,

I'm looking for a way to merge to node-sets into one, but I don't want to
have duplicate elements.

The following XPATH works, but it's slow and should be replaced by two
xsl:key statements:


Working XPATH (It is possible, that $id1 = $id2):

<xsl:variable name="all_nodes" select = "//[EMAIL PROTECTED] or @id=$id2]"/>


xsl:key statement:

<xsl:key name="element_index" match="*" use="@id"/>
<xsl:variable name="node1" select = "key('element_index', $id1)"/>
<xsl:variable name="node2" select = "key('element_index', $id2)"/>

How can I merge "node1" and "node2" into a node-set?
And what happens, if $id1 = $id2 ?

Ciao, Karsten




Reply via email to