Re: [xsl] Combining two nodesets

Subject: Re: [xsl] Combining two nodesets
From: Ivan Churkin <_qq_@xxxxxx>
Date: Thu, 4 Dec 2003 12:18:59 +0600
Hello Adam,

<?xml version="1.0"?>
<t:transform version="1.0" xmlns:t="http://www.w3.org/1999/XSL/Transform"; xmlns:ms="urn:schemas-microsoft-com:xslt">
  
  <t:template match="/">
    <t:variable name="n1" select="document('1.xml')/*/*"/>
    <t:variable name="n2" select="document('2.xml')/*/*"/>
    <t:variable name="names-rtf">
      <t:for-each select="$n1">
      <!--if 1.xml has a lot of nodes with
      repeated names then to increase performance filtrate here by
      "muenchian" algorithm-->
        <n n="{name()}"/>
      </t:for-each>
    </t:variable><t:variable name="names" select="ms:node-set($names-rtf)/*"/>
    
    <t:variable name="NS" select="$n1 | $n2[not(name()=$names/@n)]"/>
    <root>
      <t:copy-of select="$NS"/>
    </root>
  </t:template>
  
</t:transform>

If your result may be an RTF then exists more effective algorithms

Ivan

AvdH> My situation is that I have a nodeset from document A and a nodset from
AvdH> document B and I want to get a node set where I have all the nodes from 
AvdH> A plus all the nodes from B that does not have a name equal to one of 
AvdH> the nodes from A.

AvdH> Which is to say if I have:

AvdH> <foo>
AvdH>     <a>A</a>
AvdH>     <b>B</b>
AvdH>     <c>C1</c>
AvdH>     <c>C2</c>
AvdH>     <d>D</d>
AvdH> </foo>

AvdH> and

AvdH> <bar>
AvdH>     <a>A2</a>
AvdH>     <d>D2</d>
AvdH>     <e>E</e>
AvdH>     <s>S</s>
AvdH> </bar>

AvdH> I want to end up with:
AvdH>     <a>A</a>
AvdH>     <b>B</b>
AvdH>     <c>C1</c>
AvdH>     <c>C2</c>
AvdH>     <d>D</d>
AvdH>     <e>E</e>
AvdH>     <s>S</s>

AvdH> Any ideas?

AvdH> Adam


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



-- 
Best regards,
 Ivan                            mailto:_qq_@xxxxxx



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


Current Thread