Will this XPath exp ever select anything?

S

Soren Kuula

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

Richard Tobin

Soren Kuula said:
/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
 
S

Soren Kuula

Hi, Richard,

Richard said:
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
 

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,999
Messages
2,570,246
Members
46,840
Latest member
BrendanG78

Latest Threads

Top