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

Re: Combining two nodesets

Subject: Re: Combining two nodesets
From: Ivan Churkin <_qq_@xxxxxx>
Date: Thu, 4 Dec 2003 12:18:59 +0600
avdh
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

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.