Compensation of IN operator

O

oSup

Hi, I have a question, how to solve this stupid problem:

Let's have this source:

<data>
<groups>
<group id="1">gr1</group>
<group id="2">gr2</group>
<group id="3">gr3</group>
</groups>

<articles>

<article aid="1">
<group id="2"/><group id="3"/>
</article>

<article aid="2">
<group id="2"/><group id="3"/><group id="1"/>
</article>

<article aid="3">
<group id="4"/>
</article>

<article aid="4">
</article>

</articles>
</data>

I'd like to select just articles, they are contained in at least one
existing group. It means articles aid={1, 2}. How to select them? Id
tried something like condition:

.... i'm in /data/articles/article scope...
count(/data/groups/group[@id = ./group/@id]) &gt; 0

correctly I should use something like IN operator, because I'm
comparing ID with group of attributes, it means
count(/data/groups/group[@id in ./group/@id]) &gt; 0

.... but XSLT doesn't have this kind of operator... well, do you have
any idea to solve that?

Thanks a lot!

osup
 
J

Joris Gillis

Tempore 14:14:45 said:
... i'm in /data/articles/article scope...
count(/data/groups/group[@id = ./group/@id]) &gt; 0

correctly I should use something like IN operator, because I'm
comparing ID with group of attributes, it means
count(/data/groups/group[@id in ./group/@id]) &gt; 0
Hi,

I don't think this problem has to do with some IN operator functionnality.

The context node changes inside a predicate, so replace '.' (=the context node) with 'current()' (=the current node)

count(/data/groups/group[@id = current()/group/@id]) &gt; 0

regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,839
Latest member
MartinaBur

Latest Threads

Top