|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Combining two nodesets
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








