Class XPathNormalizer

java.lang.Object
de.wwu.scdh.annotation.selection.rewriter.XPathRewriterBase
de.wwu.scdh.annotation.selection.rewriter.XPathNormalizer
All Implemented Interfaces:
Rewriter<DOMResource,XPathRefinedByRFC5147CharScheme,XPathRefinedByRFC5147CharScheme>
Direct Known Subclasses:
XPathNormalizerWithXPath

The same position (or range) in a DOMResource can be selected by different pairs of XPaths and RFC 5147 character schemes (or range schemes), i.e. *referentially equal* selectors may have different values. Normalization maps referentially equal selectors to the same selector. This XPathNormalizer is a base class for such normalization tasks.

Normalization of selectors is a 2-stage process: 1) In the first stage, the text position (or range) which is referenced by the selector, has to be found. A pair containing a text node and an RFC 5147 character scheme position is returned. 2) In the second stage, this position is expressed as a selector again, i.e., the node is referenced with an XPath, where the XPath may be written as a path expression descending from the root element, or from the deepest element with an XML-ID, etc., and even the character scheme component of the selector may be recalculated.

There is **not** the one and only normalization. Both stages of the normalization process may be implemented differently, leading to different results. For corner cases, even the first stage may lead to different results.

This class implements the first stage of the normalization process. The algorithm is selected by values of the Mode enum type, which is passed to the normalization methods. The second stage of the normalization process has to be implemented by subclasses of the abstract base class.

XPath expressions to be normalized may be arbitrary XPath 4.0 expressions which select a single node from the DOMResource. Expressions selecting not exactly one node result in an SelectorException.