simple XPATH question

W

woody.hagar

Hi All, this is fairly simple, but I am a noob. Take a look at this:

<entry dn="CN=JB01,OU=Domain Controllers,DC=www,DC=site,DC=org">
<objectclass>
<oc-value>top</oc-value>
<oc-value>person</oc-value>
<oc-value>organizationalPerson</oc-value>
<oc-value>user</oc-value>
<oc-value>computer</oc-value>
</objectclass>
<entry dn="CN=Joe Black,OU=Managed
Users,OU=GROUPER,DC=www,DC=site,DC=org">
<objectclass>
<oc-value>top</oc-value>
<oc-value>person</oc-value>
<oc-value>organizationalPerson</oc-value>
<oc-value>user</oc-value>
</objectclass>

I am trying to retrieve the attribute dn by checking the different
objectclass/oc-value, but I only want to select it if it is only a
user, not a user and a computer. Any ideas?

Thanks
woody
 
M

Martin Honnen

Hi All, this is fairly simple, but I am a noob. Take a look at this:

<entry dn="CN=JB01,OU=Domain Controllers,DC=www,DC=site,DC=org">
<objectclass>
<oc-value>top</oc-value>
<oc-value>person</oc-value>
<oc-value>organizationalPerson</oc-value>
<oc-value>user</oc-value>
<oc-value>computer</oc-value>
</objectclass>
<entry dn="CN=Joe Black,OU=Managed
Users,OU=GROUPER,DC=www,DC=site,DC=org">
<objectclass>
<oc-value>top</oc-value>
<oc-value>person</oc-value>
<oc-value>organizationalPerson</oc-value>
<oc-value>user</oc-value>
</objectclass>

I am trying to retrieve the attribute dn by checking the different
objectclass/oc-value, but I only want to select it if it is only a
user, not a user and a computer. Any ideas?

Assuming a root element
/root/entry[objectclass/oc-value = 'user' and
not(objectclass/oc-value = 'computer')]/@dn
 
V

Volkm@r

Hi All, this is fairly simple, but I am a noob. Take a look at this:

<entry dn="CN=JB01,OU=Domain Controllers,DC=www,DC=site,DC=org">
<objectclass>
<oc-value>top</oc-value>
<oc-value>person</oc-value>
<oc-value>organizationalPerson</oc-value>
<oc-value>user</oc-value>
<oc-value>computer</oc-value>
</objectclass>
<entry dn="CN=Joe Black,OU=Managed
Users,OU=GROUPER,DC=www,DC=site,DC=org">
<objectclass>
<oc-value>top</oc-value>
<oc-value>person</oc-value>
<oc-value>organizationalPerson</oc-value>
<oc-value>user</oc-value>
</objectclass>

I am trying to retrieve the attribute dn by checking the different
objectclass/oc-value, but I only want to select it if it is only a
user, not a user and a computer. Any ideas?

Thanks
woody
<xsl:template
match="entry[objectclass/oc-value[.='user']][objectclass/oc-value[not(.='computer')]]/@dn"/>
<xsl:value-of select="."/>
</xsl:match>

To make it more obvious, it is
match="entry[][]/@dn"
with these two conditions
1. [objectclass/oc-value[.='user']
2. [objectclass/oc-value[not(.='computer')]]

HTH
Volkm@r
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top