Class XPathRefinedByRFC5147CharSchemeBackwardMapper

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

public class XPathRefinedByRFC5147CharSchemeBackwardMapper extends XPathRewriterBase implements Rewriter<MappedDOMResource,XPathRefinedByRFC5147CharScheme,XPathRefinedByRFC5147CharScheme>
Map an XPathRefinedByRFC5147CharScheme point into an image to a XPathRefinedByRFC5147CharScheme point into the XML preimage.

The mapping involves 3 steps:

1) In the Xdm Value representation of the image, descend to the image'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 preimage resource. We now have the image's text node and the char scheme position inside it. Note, that there may be one or no text node in the preimage, that corresponds to the same text node in the image. So the next step will be applied to maybe a single or no nodes.

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.

  • Constructor Details

    • XPathRefinedByRFC5147CharSchemeBackwardMapper

      public XPathRefinedByRFC5147CharSchemeBackwardMapper(net.sf.saxon.s9api.XPathCompiler xPathCompiler, String xpath)
  • 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,XPathRefinedByRFC5147CharScheme>
      Parameters:
      preimage - the Resource to operate on
      position - 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 //