simple XPATH question

Discussion in 'XML' started by woody.hagar@gmail.com, May 24, 2005.

  1. Guest

    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
     
    , May 24, 2005
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, May 24, 2005
    #2
    1. Advertising

  3. Volkm@r Guest

    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
     
    Volkm@r, May 24, 2005
    #3
  4. Guest

    Wonderful, thank you very much.
     
    , May 24, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,983
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,426
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    532
  4. goog
    Replies:
    0
    Views:
    514
  5. Tjerk Wolterink

    XPath: efficiency in xpath expressions

    Tjerk Wolterink, Nov 13, 2004, in forum: XML
    Replies:
    1
    Views:
    1,654
    Richard Tobin
    Nov 13, 2004
Loading...

Share This Page