Class XPathRefinedByRFC5147CharSchemeToTextForwardMapper

java.lang.Object
de.wwu.scdh.annotation.selection.rewriter.XPathRewriterBase
de.wwu.scdh.annotation.selection.rewriter.XPathRefinedByRFC5147CharSchemeToTextForwardMapper
All Implemented Interfaces:
Rewriter<MappedDOMResource,XPathRefinedByRFC5147CharScheme,RFC5147CharScheme>

public class XPathRefinedByRFC5147CharSchemeToTextForwardMapper extends XPathRewriterBase implements Rewriter<MappedDOMResource,XPathRefinedByRFC5147CharScheme,RFC5147CharScheme>
Map an 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.

  • Field Details

  • Constructor Details

    • XPathRefinedByRFC5147CharSchemeToTextForwardMapper

      public XPathRefinedByRFC5147CharSchemeToTextForwardMapper(net.sf.saxon.s9api.XPathCompiler xPathCompiler, String ignoredXpath)
  • Method Details

    • rewrite

      Rewrite a Point in a Resource to 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 List of Points.

      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 monad Optional for 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 a List.

      Specified by:
      rewrite in interface Rewriter<MappedDOMResource,XPathRefinedByRFC5147CharScheme,RFC5147CharScheme>
      Parameters:
      preimage - the Resource to operate on
      preimagePoint - a Point in the resource
      config - a record with configuration parameters
      Returns:
      the same point like position, but in a recalculated representation and wrapped into a List, 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 //