Will this XPath exp ever select anything?

Discussion in 'XML' started by Soren Kuula, Apr 10, 2005.

  1. Soren Kuula

    Soren Kuula Guest

    /a//b[/b]//a

    ?

    - or am I wrong in that it will never select a node for any document?

    I read it "the document element must be an 'a' element; there must be a
    'b' element x which is a descendant of the document element, or is the
    element. Furthermore, the document element must be a 'b' element, and x
    is an 'a' element or has an 'a' descendant...

    -- so, the document element is an 'a' and 'b' element at the same time.
    Not many documents like that around. Or did I misunderstand something
    about the absolute path exp in the predicate?

    Found the expression in "Automata theory for XML researchers", by Frank
    Neven.

    Soren
     
    Soren Kuula, Apr 10, 2005
    #1
    1. Advertising

  2. In article <Lyf6e.111061$>,
    Soren Kuula <dongfang-remove_this@remove_this-bitplanet.net> wrote:

    >/a//b[/b]//a


    >- or am I wrong in that it will never select a node for any document?


    No, you're right. It means an "a" descendant of a "b" that is in a
    document with a "b" root element and which is a descendant of the "a"
    root element. So it can never match.

    Perhaps it was meant to be

    /a//b//a

    or something similar.

    -- Richard
     
    Richard Tobin, Apr 10, 2005
    #2
    1. Advertising

  3. Soren Kuula

    Soren Kuula Guest

    Hi, Richard,

    Richard Tobin wrote:
    > No, you're right. It means an "a" descendant of a "b" that is in a
    > document with a "b" root element and which is a descendant of the "a"
    > root element. So it can never match.


    Yes, I should of course have expressed myself in terms of the final 'a'
    element that would have been the result of the match, with the predicate
    corrected, and a suitable tree.

    > Perhaps it was meant to be
    >
    > /a//b//a


    Yes. I will see if I can rewrite his language for XPath match
    determination to work .. if I get it right, I must have understood his
    article then :)

    Hey, wouldn't

    /a//b
    and
    //b[/a]

    always match the same nodes (leaving out any discussion of which look
    the prettiest :) ?

    There's also an example of an NFA with two states -- both acceptor
    states, and no transitions undefined or leading to a no-state condition.
    It's supposed to match only some strings. I guess the article was rushed
    out :)

    Thanks.

    Soren
     
    Soren Kuula, Apr 10, 2005
    #3
    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. Timo Nentwig

    XPath: //B[2] doesn't select anything

    Timo Nentwig, Feb 5, 2004, in forum: XML
    Replies:
    4
    Views:
    779
    Richard Tobin
    Feb 5, 2004
  2. 5tein
    Replies:
    1
    Views:
    485
    Patrick TJ McPhee
    Apr 30, 2004
  3. Ever see anything like this?

    , Feb 21, 2006, in forum: C Programming
    Replies:
    4
    Views:
    335
  4. Jason
    Replies:
    0
    Views:
    227
    Jason
    Jul 6, 2004
  5. palmiere
    Replies:
    1
    Views:
    467
    Erwin Moller
    Feb 9, 2004
Loading...

Share This Page