Boolean operators in predicates

Predicates may contain the Boolean operators "and" and "or".

//TITLE[@style="Pop" and @evaluation=4] Selection of all "TITLE" elements which have a "style" attribute, which has the value "Pop" and at the same time an "evaluation" attribute with the value 4.
//TITLE[@style="Pop" or @evaluation > 2] Selection of all "TITLE" elements which have a "style" attribute, which has the value "Pop" or an "evaluation" attribute with a value greater than 2.

Cascading predicates

Apart from the Boolean operators, predicates can be cascaded. A cascade of predicates can be described as a series connection of filters. At first, a node volume is filtered. The result is at the same time the initial volume for the second predicate and so on.

//section[para][@type='warning']

At first, all "section" elements are selected. The first predicate only keeps those elements having a "para" child element. This result volume is filtered again. Only those elements remain whose "type" attribute has the value "warning".

 

<< back next >>

Copyright © dpunkt.verlag GmbH 2007
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "Professionelle XML-Verarbeitung mit Word" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

dpunkt.verlag GmbH, Ringstraße 19B, 69115 Heidelberg, fon 06221-14830, fax 06221-148399, hallo(at)dpunkt.de