Class XPathRefinedByRFC5147CharSchemeForwardMapper
- All Implemented Interfaces:
Rewriter<MappedDOMResource,XPathRefinedByRFC5147CharScheme, XPathRefinedByRFC5147CharScheme>
XPathRefinedByRFC5147CharScheme point inside a
preimage to the analog point inside the derived image.The mapping involves 3 steps:
1) Descend to the preimage's text node that has the point and save this node and the char scheme position inside it.
2) Get the corresponding node of the derived image resource. We now have the image's text node and the char scheme position inside it. Note, that there may be multiple text nodes in the image, that correspond to the same text node in the preimage. So the next step will be applied to each of these pairs of nodes and char scheme positions.
3) Calculate a normalized pair of path expression and char scheme that is referentially equivalent. This involves getting the path expression using an XPath that returns a path expression, and then recalculating the position inside the fragment that is selected by this path expression. The XPath that returns a path expression is a configuration feature of this rewriter and thus passed to the constructor.
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.wwu.scdh.annotation.selection.Rewriter
Rewriter.Direction -
Field Summary
Fields inherited from class de.wwu.scdh.annotation.selection.rewriter.XPathRewriterBase
EMPTY_NAMESPACE, TEXT_LEAF, TRACE_TEXT_LEAF, xpath, xPathCompiler -
Constructor Summary
ConstructorsConstructorDescriptionXPathRefinedByRFC5147CharSchemeForwardMapper(net.sf.saxon.s9api.XPathCompiler xPathCompiler, String xpath) -
Method Summary
Modifier and TypeMethodDescriptionrewrite(MappedDOMResource preimage, XPathRefinedByRFC5147CharScheme preimagePoint, RewriterConfig config) Methods inherited from class de.wwu.scdh.annotation.selection.rewriter.XPathRewriterBase
getDeepTextNodeAtPositionStepOverEnd, getDeepTextNodeAtPositionStopAtEnd, getDepth, getDepth, getDescendantTextNodesWithPosition, getFirstNodeAtPosition, getFirstOfDeepestNodesAtPosition, getLastOfDeepestNodesAtPosition, getNode, getNode, getNode, getSecondNodeAtPosition, getTextNodeAtPosition, getTextNodesWithPosition, getXPath, pathExpressionWithXPath, posInNormalizedNode, postProcForwardPaths, replaceEmptyNamespace, replaceTextLeaf, replaceTextLeaf, replaceTraceTextLeaf, reportNotFound, unespace
-
Constructor Details
-
XPathRefinedByRFC5147CharSchemeForwardMapper
public XPathRefinedByRFC5147CharSchemeForwardMapper(net.sf.saxon.s9api.XPathCompiler xPathCompiler, String xpath)
-
-
Method Details
-
rewrite
public List<XPathRefinedByRFC5147CharScheme> rewrite(MappedDOMResource preimage, XPathRefinedByRFC5147CharScheme preimagePoint, RewriterConfig config) throws SelectorException Rewrite aPointin aResourceto the same point, but with a different (or potentially different) representation.A normalizer will typically return one recalculated point. A so-called forward mapper, which maps a point from a preimage resource to a derived resource, the image, may return zero, one or multiple points, depending on how many times a point in the preimage was mapped to the image. Thus, the return type is
ListofPoints.Note: It would be desirable, if we could declare a monadic return type with a type parameter,
M; and then use, e.g., the identity monad for normalizers, the list monad for forward mappers, the maybe monadOptionalfor reverse mappers. However, that cannot be expressed in the Java type system. Since the implied arities can easily be covered with an iterable, we use aList.- Specified by:
rewritein interfaceRewriter<MappedDOMResource,XPathRefinedByRFC5147CharScheme, XPathRefinedByRFC5147CharScheme> - Parameters:
preimage- theResourceto operate onpreimagePoint- aPointin the resourceconfig- a record with configuration parameters- Returns:
- the same point like
position, but in a recalculated representation and wrapped into aList, which should represent the occurrences of the point in document order, if an order exists in the source. - Throws:
SelectorException- when the position cannot be found in the resource //
-