Advanced context

Context need not depend only on the location of the target element in the document hierarchy. The content of the element itself may need to influence the formatting to be applied. For example, an automatically generated prefix of either 'Warning:' or 'Warnings:' may be needed, depending on whether the Warning element contains a single paragraph or a list of warning items.

Specific children

It is possible to select an element that is the parent of another specific element, by placing the name of the sub-element within square brackets:

match="X[C]"

The square brackets actually enclose a 'predicate filter'. A filter consists of a test to be made on the node to which it is attached. In this simple case, the test made is that the 'X' element (the current element) contains the 'C' element as a child.

Specific siblings

Predicate filters can be added to any element named in the pattern. For example, a filter can be added to the parent of the target element. It could be used to determine whether or not another element exists within the parent. It is therefore possible to select an element only when another specified element is present as its sibling. In the following example, the X element matches the pattern only if its parent, the P element, also contains an S element (and note that it does not matter how many times the S element occurs):

match="P[S]/X"

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset