xslt xpath

Discussion in 'XML' started by P.Hill, Oct 21, 2003.

  1. P.Hill

    P.Hill Guest

    I'm using jaxen to pull a few things out of DOM tree and having trouble
    specifying an xPath.
    /mapping/to/from[@name='Email']
    works fine, but
    /mapping/to[from@name='Email']
    doesn't.

    I'm sure it is something obvious.

    I try the following xPath:
    /mapping/to/from[@name='Email']
    on the document (simplified for the problem:
    <?xml version="1.0"?>
    <!DOCTYPE mapping SYSTEM "mapping.dtd">
    <mapping table="Contact" >
    <to name="contact" >
    <from name="Contact" />
    </to>
    <to name="email" >
    <from name="Email" />
    </to>
    </mapping>

    And I get the expected "from" node (the element with the attribute name="Email")

    But of course looking for an Element that has nothing, but the value you are matching
    is NOT very useful, so you really want some enclosing structure, in my case the enclosing
    "to" element will work just fine.
    So toward this end, I try:
    /mapping/to[from@name='Email']
    on the same DOM document and get the error.
    org.jaxen.XPathSyntaxException: Unexpected '@'
    at org.jaxen.BaseXPath.<init>(BaseXPath.java:136)
    [...]

    If
    /mapping/to/from[@name='Email']
    works fine, why doesn't
    /mapping/to[from@name='Email']

    Can anyone help?
    -Paul
     
    P.Hill, Oct 21, 2003
    #1
    1. Advertising

  2. P.Hill

    Bob Foster Guest

    /mapping/to[from/@name='Email']

    Bob Foster

    "P.Hill" <> wrote in message
    news:bn4dcn$si6$...
    > I'm using jaxen to pull a few things out of DOM tree and having trouble
    > specifying an xPath.
    > /mapping/to/from[@name='Email']
    > works fine, but
    > /mapping/to[from@name='Email']
    > doesn't.
    >
    > I'm sure it is something obvious.
    >
    > I try the following xPath:
    > /mapping/to/from[@name='Email']
    > on the document (simplified for the problem:
    > <?xml version="1.0"?>
    > <!DOCTYPE mapping SYSTEM "mapping.dtd">
    > <mapping table="Contact" >
    > <to name="contact" >
    > <from name="Contact" />
    > </to>
    > <to name="email" >
    > <from name="Email" />
    > </to>
    > </mapping>
    >
    > And I get the expected "from" node (the element with the attribute

    name="Email")
    >
    > But of course looking for an Element that has nothing, but the value you

    are matching
    > is NOT very useful, so you really want some enclosing structure, in my

    case the enclosing
    > "to" element will work just fine.
    > So toward this end, I try:
    > /mapping/to[from@name='Email']
    > on the same DOM document and get the error.
    > org.jaxen.XPathSyntaxException: Unexpected '@'
    > at org.jaxen.BaseXPath.<init>(BaseXPath.java:136)
    > [...]
    >
    > If
    > /mapping/to/from[@name='Email']
    > works fine, why doesn't
    > /mapping/to[from@name='Email']
    >
    > Can anyone help?
    > -Paul
    >
    >
    >
    >
     
    Bob Foster, Oct 22, 2003
    #2
    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:
    2,010
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,480
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    555
  4. goog
    Replies:
    0
    Views:
    527
  5. Tjerk Wolterink

    XPath: efficiency in xpath expressions

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

Share This Page