xsl-list
[Top] [All Lists]

Re: Need some help with an XPath

2003-02-21 14:57:30
Use:

/*/*/service[
                   not(@servId = /*/*[1]/*/@servId
                      and
                         @servId = /*/*[2]/*/@servId
                      and
                        @servId = /*/*[3]/*/@servId
                         )
                    ]



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL



"Adam van den Hoven" <list(_at_)adamvandenhoven(_dot_)com> wrote in message
news:2CFBE0D9CD992F41BE13069173C5C1C94B8445(_at_)c2kxch(_dot_)cucbc(_dot_)com(_dot_)(_dot_)(_dot_)
I have a node set that looks something like:

<branch>
    <service servId="Service 1" />
    <service servId="Service 3" />
    <service servId="Service 4" />
</branch>
<branch>
    <service servId="Service 1" />
    <service servId="Service 2" />
    <service servId="Service 4" />
</branch>
<branch>
    <service servId="Service 1" />
    <service servId="Service 3" />
    <service servId="Service 4" />
</branch>

Now what I want is a set of all the service elements that do not appear
in ALL the branch Elements. In this case I'm hoping for

    <service servId="Service 3" />
    <service servId="Service 2" />
    <service servId="Service 3" />

Although the extra "Service 3" doesn't really need to be there, the way
I'll be using it doesn't care.

Now my first thought was:

"All the services elements where the number of branch elements does not
equal the number of branch elements containing this service element"

the XPath for this (assuming $branch contains the nodeset in question) :

service[count($branch) != count($branch[service = ???])]

The problem is that I'm not sure what to replace the ??? with. Clearly a
period isn't going to work. Neither is current().

Now I could use a for-each but I know better than to start there. I have
a suspicion that keys will fit in the solution but I'm not 100% sure
where.

Any ideas?

H. Adam van den Hoven
Web Developer
Credit Union Central of BC
p 604 7306380
e avandenhoven(_at_)cucbc(_dot_)com


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






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



<Prev in Thread] Current Thread [Next in Thread>