Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > simple XPATH question

Reply
Thread Tools

simple XPATH question

 
 
woody.hagar@gmail.com
Guest
Posts: n/a
 
      05-24-2005
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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      05-24-2005


http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> 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
--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Volkm@r
Guest
Posts: n/a
 
      05-24-2005
(E-Mail Removed) wrote:
> 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
 
Reply With Quote
 
woody.hagar@gmail.com
Guest
Posts: n/a
 
      05-24-2005
Wonderful, thank you very much.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
XPath: efficiency in xpath expressions Tjerk Wolterink XML 1 11-13-2004 06:03 PM
Are there any XPath parsers that generate XPath trees? goog XML 0 01-14-2004 01:47 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments