Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Node set operators

0 views
Skip to first unread message

Dave & Lisa

unread,
Dec 17, 2001, 8:08:30 PM12/17/01
to
Hi,

Are there nodeset functions which can add nodesets to find produce a union,
subtract to find the intersection etc?

I have two nodelists which represent files on a local and remote server and
I want to transform into a list of files to replicate

i.e.

<locallist>
<file name="file1.txt"/>
<file name="file2.txt"/>
<file name="file3.txt"/>
...
</locallist>
<remotelist>
<file name="file1.txt"/>
<file name="file2.txt"/>
<file name="file3.txt"/>
...
</remotelist>

And I want a list of all nodes from remotelist which are not in locallist.
I've done this using <xsl:if> but is there a better way?

Dave


Rich Doughty

unread,
Dec 17, 2001, 8:51:54 PM12/17/01
to
Dave & Lisa wrote:

Hi,

Are there nodeset functions which can add nodesets to find produce a union,
subtract to find the intersection etc?

I have two nodelists which represent files on a local and remote server and
I want to transform into a list of files to replicate

you can use | for the Union. Difference and Intersection techniques can
be found here:

http://www.dpawson.co.uk/xsl/sect2/muench.html#d197e74

theres a lot of good stuff on this site.

--
Rich Doughty
http://www.richdoughty.net/

Dimitre Novatchev

unread,
Dec 18, 2001, 3:20:52 PM12/18/01
to
In case your source xml document is the following:

<t>


<locallist>
<file name="file1.txt" />
<file name="file2.txt" />
<file name="file3.txt" />

</locallist>
<remotelist>
<file name="file1.txt" />
<file name="file2.txt" />
<file name="file3.txt" />

<file name="file4.txt" />
<file name="file5.txt" />
</remotelist>
</t>

Use:

/*/remotelist/*[not(@name = /*/locallist/*/@name)]

The above XPath expression returns the last two children elements of
"remotelist".

Hope this helped.

Cheers,
Dimitre Novatchev.

P.S. This solution was tested to be correct with the XPath Visualizer.


"Dave & Lisa" <lisaa...@ozemail.com.au> wrote in message
news:5WwT7.95639$li3.8...@ozemail.com.au...

Dave & Lisa

unread,
Dec 19, 2001, 9:00:50 PM12/19/01
to
Hi,

This method only works if the nodes in the two lists are the same actual
node from the source document. In my case the remotefiles and localfiles
contain duplicate elements, but they are not the same node in the xml
document so | will return both elements.

Dave

"Rich Doughty" <ri...@dufty.karoo.co.uk> wrote in message
news:3C1EA13A...@dufty.karoo.co.uk...

0 new messages