url - Universität zu Lübeck
url - Universität zu Lübeck
url - Universität zu Lübeck
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
3.2. A MODEL FOR PATH EXPRESSIONS 53<br />
The set of all regular expressions that can be built with the symbol alphabet<br />
Σ and α is denoted by REG Σ,α<br />
Example 8 The linear path expression p = /a//b/c/∗/d with Σ(p) = {a, b, c, d} leads<br />
to the following regular path expression:<br />
a (a|b|c|d|α) ∗ k<br />
b c (a|b|c|d|α) d<br />
Definition 15 Any regular expression r ∈ REG Σ,α defines a language L r consisting<br />
of all words that match the pattern of the path expression.<br />
<br />
We use regular path expressions when building finite automata in section 7.2.2.<br />
The reverse transformation from regular expressions to linear path expressions<br />
is not always possible: for instance, for the regular expressions a(b|c)d there is<br />
no corresponding linear path expression because the choice (b|c) cannot be expressed.<br />
With the wildcard (*) a path expression would accept all symbols and<br />
not only b and c. With a normal node test the choice is not expressible.<br />
Even in full XPath 1.0 a(b|c)d cannot be expressed in a simple way. A workaround<br />
may use a node function called name and looks like /a/∗[name(.) = ′ b ′ or name(.) = ′<br />
c ′ ]/d.<br />
XPath 2.0 supports a choice in node tests. The corresponding path expression is<br />
/a/(b|c)/d.<br />
3.2.2 Tailing Predicates and Normalization<br />
The grammar for general path expressions allows only one predicate that is always<br />
the last part of a path expression. This raises the question whether these<br />
tailing predicates are expressive enough for realistic queries. With a small example<br />
we show how a more general path expression with multiple predicates can be<br />
normalized to an equivalent path expression with one tailing predicate:<br />
e 1 = //a/b[//c = ′ x ′ ]/d[/e = ′ y ′ ]/f<br />
The XPath expression e 1 returns all elements with the label f that are child of an<br />
element d having another child e that has the value y. In addition, the element<br />
d must be the child of an element b that is ancestor of a c with value x. Finally,<br />
b is child of an element a that appears somewhere in the XML data. The same<br />
semantic can be expressed with path expression e 2 .<br />
e 2 = //a/b/d/f[../e = ′ y ′ and ../..//c = ′ x ′ ]<br />
The normalization process combines all predicates by using AND statements. The<br />
resulting predicate (with multiple value comparisons) is moved to the end while