Class XPathRefinedByRFC5147CharSchemeToTextForwardMapper
- All Implemented Interfaces:
Rewriter<MappedDOMResource,XPathRefinedByRFC5147CharScheme, RFC5147CharScheme>
XPathRefinedByRFC5147CharScheme point inside a
preimage to the analog point inside the derived plain text 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 the RFC5147 character scheme, i.e. the inter-glyph character position, by summing up the lengths of text nodes preceding the node gotten in step 2 in the image and add the char scheme position gotten in step 2. This sum is the new inter-glyph character position in the plain text image.
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.wwu.scdh.annotation.selection.Rewriter
Rewriter.Direction -
Field Summary
FieldsFields inherited from class de.wwu.scdh.annotation.selection.rewriter.XPathRewriterBase
EMPTY_NAMESPACE, TEXT_LEAF, TRACE_TEXT_LEAF, xpath, xPathCompiler -
Constructor Summary
ConstructorsConstructorDescriptionXPathRefinedByRFC5147CharSchemeToTextForwardMapper(net.sf.saxon.s9api.XPathCompiler xPathCompiler, String ignoredXpath) -
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
-
Field Details
-
XPATH
- See Also:
-
-
Constructor Details
-
XPathRefinedByRFC5147CharSchemeToTextForwardMapper
public XPathRefinedByRFC5147CharSchemeToTextForwardMapper(net.sf.saxon.s9api.XPathCompiler xPathCompiler, String ignoredXpath)
-
-
Method Details
-
rewrite
public List<RFC5147CharScheme> 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, RFC5147CharScheme> - 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 //
-