rewrite(
* This abstract method must be implemented by normalizers. It
* returns the normalized path to the node given as argument.
*
- * @param node an {@link XdmNode} to which the normlized path must be generated to
- * @param escaped whether or not the normalized XPath is to be escaped for X-processing, e.g., ' escaped to '.
+ * @param node an {@link XdmNode} to which the normalized path must be generated to
+ * @param escaped whether or not the normalized XPath is to be escaped for X-processing, e.g.,
+ * ' escaped to '.
* @return the normalized XPath expression as a String
- * @see XPathNormalizer#getTextNodeAtPosition(String, int, boolean)
+ * @see XPathRewriterBase#getTextNodeAtPosition(S9ApiResource, String, int, Mode)
*/
protected abstract String getNormalizedXPath(DOMResource resource, XdmNode node, boolean escaped)
throws SelectorException;
diff --git a/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathNormalizerWithXPath.java b/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathNormalizerWithXPath.java
index 2b5860f..fd5f3d5 100644
--- a/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathNormalizerWithXPath.java
+++ b/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathNormalizerWithXPath.java
@@ -2,6 +2,8 @@
import de.wwu.scdh.annotation.selection.*;
import de.wwu.scdh.annotation.selection.resource.DOMResource;
+import de.wwu.scdh.annotation.selection.resource.S9ApiResource;
+import net.sf.saxon.s9api.XPathCompiler;
import net.sf.saxon.s9api.XdmNode;
/**
@@ -10,14 +12,14 @@
* context node in question.
*
* The context item on which the XPath will be evaluated, is
- * determined by {@link XPathNormalizer#getTextNodeAtPosition(String, int,boolean)}.
+ * determined by {@link XPathRewriterBase#getTextNodeAtPosition(S9ApiResource, String, int, Mode)}.
* This is generally a text node.
*/
public class XPathNormalizerWithXPath extends XPathNormalizer {
/**
* An XPath expression suitable for normalizing path expressions
- * to nodes.
+ * to nodes.
*
* Generates a path expression using the path(.)
* XPath function. This result in a path expression stepping from
@@ -26,6 +28,13 @@ public class XPathNormalizerWithXPath extends XPathNormalizer {
*/
public static final String PATH_FUNCTION_XPATH = "path(.)";
+ /**
+ * {@inheritDoc}
+ */
+ public XPathNormalizerWithXPath(XPathCompiler xPathCompiler, String xpath) {
+ super(xPathCompiler, xpath);
+ }
+
/**
* An XPath expression suitable for normalizing path expressions
* to nodes.
@@ -35,7 +44,7 @@ public class XPathNormalizerWithXPath extends XPathNormalizer {
* notation.
*/
public static final String FROM_ROOT_CLARK_XPATH =
- "let $ctx:=., $elsteps:=$ctx/ancestor-or-self::element(), $txtstep:=$ctx[self::text()] return ($elsteps ! (let $step:=., $ns:=namespace-uri($step), $name:=name($step), $pos:=count($step/preceding-sibling::node()[name() eq $name])+1 return concat('/Q{', $ns, '}', $name, '[', $pos, ']')), $txtstep ! (concat('/text()[', count($txtstep/preceding-sibling::text())+1, ']'))) => string-join('')";
+ "let $ctx:=., $elSteps:=$ctx/ancestor-or-self::element(), $txtStep:=$ctx[self::text()] return ($elSteps ! (let $step:=., $ns:=namespace-uri($step), $name:=name($step), $pos:=count($step/preceding-sibling::node()[name() eq $name])+1 return concat('/Q{', $ns, '}', $name, '[', $pos, ']')), $txtStep ! (concat('/text()[', count($txtStep/preceding-sibling::text())+1, ']'))) => string-join('')";
/**
* An XPath expression suitable for normalizing path expressions
@@ -46,20 +55,7 @@ public class XPathNormalizerWithXPath extends XPathNormalizer {
* node. Element names are QNames in Clark notation.
*/
public static final String FROM_DEEPEST_ID_CLARK_XPATH =
- "let $ctx:=., $elsteps:=$ctx/ancestor-or-self::element(), $ids:=for $step in 1 to count($elsteps) return if ($elsteps[$step]/@xml:id) then $step else -1, $idat:=$ids[. ne -1][last()], $idstep:=if ($idat) then concat('id('', $elsteps[$idat]/@xml:id, '')') else '', $txtstep:=$ctx[self::text()] return concat($idstep, ($elsteps[position() gt $idat or empty($idat)] ! (let $step:=., $ns:=namespace-uri($step), $name:=name($step), $pos:=count($step/preceding-sibling::node()[name() eq $name])+1 return concat('/Q{', $ns, '}', $name, '[', $pos, ']')), $txtstep ! (concat('/text()[', count($txtstep/preceding-sibling::text())+1, ']'))) => string-join(''))";
-
- protected final String xpath;
-
- /**
- * Create a new {@link XPathNormalizerWithXPath} normalizer for a
- * {@link DOMResource}.
- *
- * @param xpath an XPath expression which will be evaluated on a context node for normalization
- */
- public XPathNormalizerWithXPath(String xpath) {
- super();
- this.xpath = xpath;
- }
+ "let $ctx:=., $elSteps:=$ctx/ancestor-or-self::element(), $ids:=for $step in 1 to count($elSteps) return if ($elSteps[$step]/@xml:id) then $step else -1, $idAt:=$ids[. ne -1][last()], $idStep:=if ($idAt) then concat('id('', $elSteps[$idAt]/@xml:id, '')') else '', $txtStep:=$ctx[self::text()] return concat($idStep, ($elSteps[position() gt $idAt or empty($idAt)] ! (let $step:=., $ns:=namespace-uri($step), $name:=name($step), $pos:=count($step/preceding-sibling::node()[name() eq $name])+1 return concat('/Q{', $ns, '}', $name, '[', $pos, ']')), $txtStep ! (concat('/text()[', count($txtStep/preceding-sibling::text())+1, ']'))) => string-join(''))";
/**
* Get the path to the {@link XdmNode} given as parameter by using
@@ -67,10 +63,6 @@ public XPathNormalizerWithXPath(String xpath) {
*/
@Override
protected String getNormalizedXPath(DOMResource resource, XdmNode node, boolean escaped) throws SelectorException {
- return pathExpressionWithXPath(getXPath(), node, escaped, resource.getProcessor());
- }
-
- public String getXPath() {
- return xpath;
+ return pathExpressionWithXPath(getXPath(), node, escaped);
}
}
diff --git a/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeBackwardMapper.java b/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeBackwardMapper.java
index 7177143..6f5d454 100644
--- a/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeBackwardMapper.java
+++ b/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeBackwardMapper.java
@@ -6,6 +6,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
+import net.sf.saxon.s9api.XPathCompiler;
import net.sf.saxon.s9api.XdmNode;
import org.apache.commons.lang3.tuple.Pair;
@@ -37,16 +38,11 @@
public class XPathRefinedByRFC5147CharSchemeBackwardMapper extends XPathRewriterBase
implements Rewriter {
- protected final String xpath;
-
/**
- * Create a {@link XPathRefinedByRFC5147CharSchemeBackwardMapper}
- * for a {@link MappedDOMResource}.
- *
- * @param xpath an XPath expression which will be evaluated on a context node for normalization
+ * {@inheritDoc}
*/
- public XPathRefinedByRFC5147CharSchemeBackwardMapper(String xpath) {
- this.xpath = xpath;
+ public XPathRefinedByRFC5147CharSchemeBackwardMapper(XPathCompiler xPathCompiler, String xpath) {
+ super(xPathCompiler, xpath);
}
/**
@@ -72,20 +68,11 @@ public List rewrite(
// step 3: rebase each image node
List transformed = new ArrayList();
if (preimageNode.isPresent()) {
- String normalizedXPath = pathExpressionWithXPath(
- getXPath(), preimageNode.get(), config.getEscaped(), preimage.getProcessor());
- XdmNode normalizedNode =
- getNode(preimage.getContents(), unespace(normalizedXPath), preimage.getProcessor());
+ String normalizedXPath = pathExpressionWithXPath(getXPath(), preimageNode.get(), config.getEscaped());
+ XdmNode normalizedNode = getNode(preimage.getContents(), unespace(normalizedXPath));
Integer normalizedPos = posInNormalizedNode(preimageNode.get(), imagePair.getRight(), normalizedNode);
transformed.add(new XPathRefinedByRFC5147CharScheme(normalizedXPath, normalizedPos));
}
return transformed;
}
-
- /**
- * Returns the XPath the mapper instance was configured with.
- */
- public String getXPath() {
- return xpath;
- }
}
diff --git a/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeForwardMapper.java b/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeForwardMapper.java
index ad3876a..e851932 100644
--- a/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeForwardMapper.java
+++ b/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeForwardMapper.java
@@ -5,6 +5,7 @@
import de.wwu.scdh.annotation.selection.resource.MappedDOMResource;
import java.util.ArrayList;
import java.util.List;
+import net.sf.saxon.s9api.XPathCompiler;
import net.sf.saxon.s9api.XdmNode;
import org.apache.commons.lang3.tuple.Pair;
@@ -35,16 +36,11 @@
public class XPathRefinedByRFC5147CharSchemeForwardMapper extends XPathRewriterBase
implements Rewriter {
- protected final String xpath;
-
/**
- * Create a {@link XPathRefinedByRFC5147CharSchemeForwardMapper}
- * for a {@link MappedDOMResource}.
- *
- * @param xpath an XPath expression which will be evaluated on a context node for normalization
+ * {@inheritDoc}
*/
- public XPathRefinedByRFC5147CharSchemeForwardMapper(String xpath) {
- this.xpath = xpath;
+ public XPathRefinedByRFC5147CharSchemeForwardMapper(XPathCompiler xPathCompiler, String xpath) {
+ super(xPathCompiler, xpath);
}
/**
@@ -54,7 +50,7 @@ public XPathRefinedByRFC5147CharSchemeForwardMapper(String xpath) {
public List rewrite(
MappedDOMResource preimage, XPathRefinedByRFC5147CharScheme preimagePoint, RewriterConfig config)
throws SelectorException {
- // step 1: normalize to pair of text node and position
+ // step 1: normalize to a pair of text node and position
Pair preimagePair =
getTextNodeAtPosition(preimage, preimagePoint.getXPath(), preimagePoint.getChar(), config.getMode());
// step 2: map text node from preimage to list of text nodes from image
@@ -62,21 +58,12 @@ public List rewrite(
// step 3: rebase in image using configured XPath
List transformed = new ArrayList();
for (XdmNode imageNode : imageNodes) {
- String normalizedXPath =
- pathExpressionWithXPath(getXPath(), imageNode, config.getEscaped(), preimage.getProcessor());
- XdmNode normalizedNode =
- getNode(preimage.getImage().getContents(), unespace(normalizedXPath), preimage.getProcessor());
+ String normalizedXPath = pathExpressionWithXPath(getXPath(), imageNode, config.getEscaped());
+ XdmNode normalizedNode = getNode(preimage.getImage().getContents(), unespace(normalizedXPath));
Integer normalizedPos = posInNormalizedNode(imageNode, preimagePair.getRight(), normalizedNode);
transformed.add(
new XPathRefinedByRFC5147CharScheme(postProcForwardPaths(normalizedXPath, config), normalizedPos));
}
return transformed;
}
-
- /**
- * Returns the XPath the mapper instance was configured with.
- */
- public String getXPath() {
- return xpath;
- }
}
diff --git a/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeToTextBackwardMapper.java b/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeToTextBackwardMapper.java
index 46519c0..a8bd250 100644
--- a/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeToTextBackwardMapper.java
+++ b/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeToTextBackwardMapper.java
@@ -7,6 +7,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
+import net.sf.saxon.s9api.XPathCompiler;
import net.sf.saxon.s9api.XdmNode;
import org.apache.commons.lang3.tuple.Pair;
@@ -38,23 +39,13 @@
public class XPathRefinedByRFC5147CharSchemeToTextBackwardMapper extends XPathRewriterBase
implements Rewriter {
- protected final String xpath;
-
/**
- * Create a {@link XPathRefinedByRFC5147CharSchemeToTextBackwardMapper}
- * for a {@link MappedDOMResource}.
- *
- * @param xpath an XPath expression which will be evaluated on a context node for normalization
+ * {@inheritDoc}
*/
- public XPathRefinedByRFC5147CharSchemeToTextBackwardMapper(String xpath) {
- this.xpath = xpath;
+ public XPathRefinedByRFC5147CharSchemeToTextBackwardMapper(XPathCompiler xPathCompiler, String xpath) {
+ super(xPathCompiler, xpath);
}
- /**
- * Utility function that returns the length of an {@link XdmItem}
- * when serialized.
- */
-
/**
* {@inheritDoc}
*/
@@ -74,24 +65,15 @@ public List rewrite(
Optional preimageNode = preimage.getCorrespondingInPreimage(textTraceElement);
// step 3: rebase each image node as char scheme only: The
// charScheme component of the preimagePair is the offset to
- // the text node in the result. Add the lenght of all text
+ // the text node in the result. Add the length of all text
// nodes before the imageNode to get the actual position.
List transformed = new ArrayList();
if (preimageNode.isPresent()) {
- String normalizedXPath = pathExpressionWithXPath(
- getXPath(), preimageNode.get(), config.getEscaped(), preimage.getProcessor());
- XdmNode normalizedNode =
- getNode(preimage.getContents(), unespace(normalizedXPath), preimage.getProcessor());
+ String normalizedXPath = pathExpressionWithXPath(getXPath(), preimageNode.get(), config.getEscaped());
+ XdmNode normalizedNode = getNode(preimage.getContents(), unespace(normalizedXPath));
Integer normalizedPos = posInNormalizedNode(preimageNode.get(), imagePair.getRight(), normalizedNode);
transformed.add(new XPathRefinedByRFC5147CharScheme(normalizedXPath, normalizedPos));
}
return transformed;
}
-
- /**
- * Returns the XPath the mapper instance was configured with.
- */
- public String getXPath() {
- return xpath;
- }
}
diff --git a/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeToTextForwardMapper.java b/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeToTextForwardMapper.java
index b7097a1..cf338d9 100644
--- a/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeToTextForwardMapper.java
+++ b/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRefinedByRFC5147CharSchemeToTextForwardMapper.java
@@ -41,16 +41,13 @@
public class XPathRefinedByRFC5147CharSchemeToTextForwardMapper extends XPathRewriterBase
implements Rewriter {
- protected final String xpath = "preceding::text()";
+ public static final String XPATH = "preceding::text()";
/**
- * Create a {@link XPathRefinedByRFC5147CharSchemeToTextForwardMapper}
- * for a {@link MappedDOMResource}.
- *
- * @param xpath an XPath expression which will be evaluated on a context node for normalization
+ * {@inheritDoc}
*/
- public XPathRefinedByRFC5147CharSchemeToTextForwardMapper(String xpath) {
- // this.xpath = xpath;
+ public XPathRefinedByRFC5147CharSchemeToTextForwardMapper(XPathCompiler xPathCompiler, String xpath) {
+ super(xPathCompiler, XPATH);
}
/**
@@ -80,7 +77,7 @@ public List rewrite(
List transformed = new ArrayList();
try {
XPathCompiler xPathCompiler = preimage.getProcessor().newXPathCompiler();
- XPathExecutable xPathExecutable = xPathCompiler.compile(xpath);
+ XPathExecutable xPathExecutable = xPathCompiler.compile(XPATH);
// for every node in image
for (XdmNode imageNode : imageNodes) {
// preimage character pos component is the offset into the image node
@@ -102,6 +99,6 @@ public List rewrite(
* Returns the XPath the mapper instance was configured with.
*/
public String getXPath() {
- return xpath;
+ return XPATH;
}
}
diff --git a/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRewriterBase.java b/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRewriterBase.java
index 5a39333..721df93 100644
--- a/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRewriterBase.java
+++ b/core/src/main/java/de/wwu/scdh/annotation/selection/rewriter/XPathRewriterBase.java
@@ -13,7 +13,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sf.saxon.s9api.Axis;
-import net.sf.saxon.s9api.Processor;
import net.sf.saxon.s9api.SaxonApiException;
import net.sf.saxon.s9api.XPathCompiler;
import net.sf.saxon.s9api.XPathExecutable;
@@ -77,12 +76,23 @@ public static String replaceTextLeaf(String xpath, RewriterConfig config) {
}
}
- // protected final DOMResource resource;
+ protected final XPathCompiler xPathCompiler;
+ protected final String xpath;
/**
* Make a new {@link XPathNormalizer} for a {@link DOMResource}.
*/
- public XPathRewriterBase() {}
+ public XPathRewriterBase(XPathCompiler xPathCompiler, String xpath) {
+ this.xPathCompiler = xPathCompiler;
+ this.xpath = xpath;
+ }
+
+ /**
+ * Returns the XPath the mapper instance was configured with.
+ */
+ public String getXPath() {
+ return xpath;
+ }
/**
* This method run the first stage of the normalization
@@ -132,7 +142,7 @@ protected Pair getTextNodeAtPosition(
*/
protected final Pair getFirstNodeAtPosition(
S9ApiResource extends XdmValue> resource, String xpath, int position) throws SelectorException {
- XdmNode fragment = getNode(resource.getContents(), xpath, resource.getProcessor());
+ XdmNode fragment = getNode(resource.getContents(), xpath);
List> nodesAtPosition = getTextNodesWithPosition(fragment, position);
if (nodesAtPosition.isEmpty()) {
return reportNotFound(xpath, position);
@@ -147,7 +157,7 @@ protected final Pair getFirstNodeAtPosition(
*/
protected final Pair getSecondNodeAtPosition(
S9ApiResource extends XdmValue> resource, String xpath, int position) throws SelectorException {
- XdmNode fragment = getNode(resource.getContents(), xpath, resource.getProcessor());
+ XdmNode fragment = getNode(resource.getContents(), xpath);
List> nodesAtPosition = getTextNodesWithPosition(fragment, position);
if (nodesAtPosition.isEmpty()) {
return reportNotFound(xpath, position);
@@ -164,7 +174,7 @@ protected final Pair getSecondNodeAtPosition(
*/
protected final Pair getFirstOfDeepestNodesAtPosition(
S9ApiResource extends XdmValue> resource, String xpath, int position) throws SelectorException {
- XdmNode fragment = getNode(resource.getContents(), xpath, resource.getProcessor());
+ XdmNode fragment = getNode(resource.getContents(), xpath);
List> nodesAtPosition = getDescendantTextNodesWithPosition(fragment, position);
if (nodesAtPosition.isEmpty()) {
return reportNotFound(xpath, position);
@@ -187,7 +197,7 @@ protected final Pair getFirstOfDeepestNodesAtPosition(
*/
protected final Pair getLastOfDeepestNodesAtPosition(
S9ApiResource extends XdmValue> resource, String xpath, int position) throws SelectorException {
- XdmNode fragment = getNode(resource.getContents(), xpath, resource.getProcessor());
+ XdmNode fragment = getNode(resource.getContents(), xpath);
List> nodesAtPosition = getDescendantTextNodesWithPosition(fragment, position);
if (nodesAtPosition.isEmpty()) {
return reportNotFound(xpath, position);
@@ -216,7 +226,7 @@ protected final Pair getLastOfDeepestNodesAtPosition(
*/
protected final Pair getDeepTextNodeAtPositionStopAtEnd(
S9ApiResource extends XdmValue> resource, String xpath, int position) throws SelectorException {
- XdmNode fragment = getNode(resource.getContents(), xpath, resource.getProcessor());
+ XdmNode fragment = getNode(resource.getContents(), xpath);
List> nodesAtPosition = getDescendantTextNodesWithPosition(fragment, position);
if (nodesAtPosition.isEmpty()) {
return reportNotFound(xpath, position);
@@ -237,7 +247,7 @@ protected final Pair getDeepTextNodeAtPositionStopAtEnd(
*/
protected final Pair getDeepTextNodeAtPositionStepOverEnd(
S9ApiResource extends XdmValue> resource, String xpath, int position) throws SelectorException {
- XdmNode fragment = getNode(resource.getContents(), xpath, resource.getProcessor());
+ XdmNode fragment = getNode(resource.getContents(), xpath);
List> nodesAtPosition = getDescendantTextNodesWithPosition(fragment, position);
if (nodesAtPosition.isEmpty()) {
return reportNotFound(xpath, position);
@@ -258,10 +268,8 @@ protected final Pair getDeepTextNodeAtPositionStepOverEnd(
* @return an {@link XdmNode} which the XPath points to
*/
protected final XdmNode getNode(DOMResource resource, String xpath) throws SelectorException {
- Processor proc = resource.getProcessor();
- XPathCompiler compiler = proc.newXPathCompiler();
try {
- XPathExecutable executable = compiler.compile(xpath);
+ XPathExecutable executable = xPathCompiler.compile(xpath);
XPathSelector selector = executable.load();
selector.setContextItem(resource.getContents());
XdmValue nodes = selector.evaluate();
@@ -292,7 +300,7 @@ protected final XdmNode getNode(DOMResource resource, String xpath) throws Selec
* @return an {@link XdmNode} which the XPath points to
*/
protected final XdmNode getNode(XdmValueResource resource, String xpath) throws SelectorException {
- return getNode(resource.getContents(), xpath, resource.getProcessor());
+ return getNode(resource.getContents(), xpath);
}
/**
@@ -300,10 +308,9 @@ protected final XdmNode getNode(XdmValueResource resource, String xpath) throws
* passed as argument. If the XPath does not evaluate to a single
* node, this method raises an {@link SelectorException}.
*/
- protected final XdmNode getNode(XdmValue value, String xpath, Processor processor) throws SelectorException {
- XPathCompiler compiler = processor.newXPathCompiler();
+ protected final XdmNode getNode(XdmValue value, String xpath) throws SelectorException {
try {
- XPathExecutable executable = compiler.compile(xpath);
+ XPathExecutable executable = xPathCompiler.compile(xpath);
XdmValue result = XdmEmptySequence.getInstance();
for (XdmItem item : value.stream().asList()) {
XPathSelector selector = executable.load();
@@ -520,14 +527,11 @@ protected String unespace(String in) {
* @param xpath the XPath for generating a path expression, e.g., fn:xpath()
* @param node the {@link XdmNode} for which to generate the path expression
* @param escaped whether the generated path expression is to be escaped
- * @param processor a Saxon {@link Processor}
*/
- protected String pathExpressionWithXPath(String xpath, XdmNode node, boolean escaped, Processor processor)
- throws SelectorException {
- XPathCompiler compiler = processor.newXPathCompiler();
+ protected String pathExpressionWithXPath(String xpath, XdmNode node, boolean escaped) throws SelectorException {
XdmValue nodes;
try {
- XPathExecutable executable = compiler.compile(xpath);
+ XPathExecutable executable = xPathCompiler.compile(xpath);
XPathSelector selector = executable.load();
selector.setContextItem(node);
nodes = selector.evaluate();
diff --git a/core/src/main/resources/xslt/xpath.xsl b/core/src/main/resources/xslt/xpath.xsl
new file mode 100644
index 0000000..5f3159c
--- /dev/null
+++ b/core/src/main/resources/xslt/xpath.xsl
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id('
+
+ ')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/src/main/resources/xslt/xpath.xspec b/core/src/main/resources/xslt/xpath.xspec
new file mode 100644
index 0000000..ae7f1b9
--- /dev/null
+++ b/core/src/main/resources/xslt/xpath.xspec
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathNormalizer.java b/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathNormalizer.java
index db8a5da..1a44015 100644
--- a/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathNormalizer.java
+++ b/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathNormalizer.java
@@ -37,7 +37,7 @@ public class TestXPathNormalizer {
private class DummyNormalizer extends XPathNormalizer {
public DummyNormalizer() {
- super();
+ super(PROC.newXPathCompiler(), "ignored");
}
@Override
diff --git a/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathNormalizerWithXPath.java b/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathNormalizerWithXPath.java
index 2d437a7..883c09c 100644
--- a/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathNormalizerWithXPath.java
+++ b/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathNormalizerWithXPath.java
@@ -28,7 +28,7 @@ public class TestXPathNormalizerWithXPath {
@Test
public void testWithPathFunction() throws SelectorException, SaxonApiException, IOException {
DOMResource resource = DOMResource.fromXML(GESANG_XML, PROC);
- XPathNormalizerWithXPath normalizer = new XPathNormalizerWithXPath("path(.)");
+ XPathNormalizerWithXPath normalizer = new XPathNormalizerWithXPath(PROC.newXPathCompiler(), "path(.)");
assertEquals("path(.)", normalizer.getXPath());
String xpath;
List result;
@@ -55,8 +55,8 @@ public void testWithPathFunction() throws SelectorException, SaxonApiException,
@Test
public void testWithDeepestIdClarkXPathOnRootElement() throws SelectorException, SaxonApiException, IOException {
DOMResource resource = DOMResource.fromXML(GESANG_XML, PROC);
- XPathNormalizerWithXPath normalizer =
- new XPathNormalizerWithXPath(XPathNormalizerWithXPath.FROM_DEEPEST_ID_CLARK_XPATH);
+ XPathNormalizerWithXPath normalizer = new XPathNormalizerWithXPath(
+ PROC.newXPathCompiler(), XPathNormalizerWithXPath.FROM_DEEPEST_ID_CLARK_XPATH);
String xpath;
List result;
XPathRefinedByRFC5147CharScheme point;
@@ -73,8 +73,8 @@ public void testWithDeepestIdClarkXPathOnRootElement() throws SelectorException,
@Test
public void testWithDeepestIdClarkXPathVerse2AppChar6() throws SelectorException, SaxonApiException, IOException {
DOMResource resource = DOMResource.fromXML(GESANG_XML, PROC);
- XPathNormalizerWithXPath normalizer =
- new XPathNormalizerWithXPath(XPathNormalizerWithXPath.FROM_DEEPEST_ID_CLARK_XPATH);
+ XPathNormalizerWithXPath normalizer = new XPathNormalizerWithXPath(
+ PROC.newXPathCompiler(), XPathNormalizerWithXPath.FROM_DEEPEST_ID_CLARK_XPATH);
String xpath;
List result;
XPathRefinedByRFC5147CharScheme point;
@@ -93,7 +93,7 @@ public void testWithDeepestIdClarkXPathVerse2AppChar6() throws SelectorException
public void testPathExpressionClarkXPathOnRootElement() throws SelectorException, SaxonApiException, IOException {
DOMResource resource = DOMResource.fromXML(GESANG_XML, PROC);
XPathNormalizerWithXPath normalizer =
- new XPathNormalizerWithXPath(XPathNormalizerWithXPath.FROM_ROOT_CLARK_XPATH);
+ new XPathNormalizerWithXPath(PROC.newXPathCompiler(), XPathNormalizerWithXPath.FROM_ROOT_CLARK_XPATH);
String xpath;
List result;
XPathRefinedByRFC5147CharScheme point;
@@ -112,7 +112,7 @@ public void testPathExpressionClarkXPathOnVerse2AppChar6()
throws SelectorException, SaxonApiException, IOException {
DOMResource resource = DOMResource.fromXML(GESANG_XML, PROC);
XPathNormalizerWithXPath normalizer =
- new XPathNormalizerWithXPath(XPathNormalizerWithXPath.FROM_ROOT_CLARK_XPATH);
+ new XPathNormalizerWithXPath(PROC.newXPathCompiler(), XPathNormalizerWithXPath.FROM_ROOT_CLARK_XPATH);
String xpath;
List result;
XPathRefinedByRFC5147CharScheme point;
diff --git a/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeBackwardMapper.java b/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeBackwardMapper.java
index 0865e03..fa4dc76 100644
--- a/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeBackwardMapper.java
+++ b/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeBackwardMapper.java
@@ -60,7 +60,7 @@ public void testTextToOneNodeWithXPathAndPos5() throws ResourceException, SaxonA
assertEquals(PROC, image.getProcessor());
assertEquals(PROC, preimage.getImage().getProcessor());
XPathRefinedByRFC5147CharSchemeBackwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeBackwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeBackwardMapper(PROC.newXPathCompiler(), "path(.)");
// ("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:head[1]/text()[1]", 5);
XPathRefinedByRFC5147CharScheme imagePoint = new XPathRefinedByRFC5147CharScheme(
"/Q{http://www.tei-c.org/ns/1.0}TEI[1]/Q{http://www.tei-c.org/ns/1.0}text[1]/Q{http://www.tei-c.org/ns/1.0}body[1]/Q{http://www.tei-c.org/ns/1.0}lg[1]/Q{http://www.tei-c.org/ns/1.0}head[1]",
@@ -82,7 +82,7 @@ public void testAmbiguityWithModeFirst() throws ResourceException, SaxonApiExcep
assertEquals(PROC, image.getProcessor());
assertEquals(PROC, preimage.getImage().getProcessor());
XPathRefinedByRFC5147CharSchemeBackwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeBackwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeBackwardMapper(PROC.newXPathCompiler(), "path(.)");
// ("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:head[1]/text()[1]", 5);
XPathRefinedByRFC5147CharScheme imagePoint = new XPathRefinedByRFC5147CharScheme(
"/Q{http://www.tei-c.org/ns/1.0}TEI[1]/Q{http://www.tei-c.org/ns/1.0}text[1]/Q{http://www.tei-c.org/ns/1.0}body[1]/Q{http://www.tei-c.org/ns/1.0}lg[1]/Q{http://www.tei-c.org/ns/1.0}head[1]",
@@ -106,7 +106,7 @@ public void testAmbiguityWithModeDeepNodeStepOverEnd()
assertEquals(PROC, image.getProcessor());
assertEquals(PROC, preimage.getImage().getProcessor());
XPathRefinedByRFC5147CharSchemeBackwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeBackwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeBackwardMapper(PROC.newXPathCompiler(), "path(.)");
// ("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:head[1]/text()[1]", 5);
XPathRefinedByRFC5147CharScheme imagePoint = new XPathRefinedByRFC5147CharScheme(
"/Q{http://www.tei-c.org/ns/1.0}TEI[1]/Q{http://www.tei-c.org/ns/1.0}text[1]/Q{http://www.tei-c.org/ns/1.0}body[1]/Q{http://www.tei-c.org/ns/1.0}lg[1]/Q{http://www.tei-c.org/ns/1.0}head[1]",
@@ -134,7 +134,7 @@ public void testBackwardToCNode() throws ResourceException, SaxonApiException, S
new XdmValueResource(GESANG_XML, transform(source, TEXT_WITH_TOC_XHTML_XSL, LIBTRACE_XML), PROC);
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeBackwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeBackwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeBackwardMapper(PROC.newXPathCompiler(), "path(.)");
List mapped = mapper.rewrite(preimage, imagePoint, config);
assertEquals(1, mapped.size());
assertEquals(
@@ -156,7 +156,7 @@ public void testBackwardHeadNode() throws ResourceException, SaxonApiException,
new XdmValueResource(GESANG_XML, transform(source, TEXT_WITH_TOC_XHTML_XSL, LIBTRACE_XML), PROC);
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeBackwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeBackwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeBackwardMapper(PROC.newXPathCompiler(), "path(.)");
List mapped = mapper.rewrite(preimage, imagePoint, config);
assertEquals(1, mapped.size());
assertEquals(
@@ -177,7 +177,7 @@ public void testHtmlBackwardHeadNode() throws ResourceException, SaxonApiExcepti
new XdmValueResource(GESANG_XML, transform(source, TEXT_WITH_TOC_HTML_XSL, LIBTRACE_XML), PROC);
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeBackwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeBackwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeBackwardMapper(PROC.newXPathCompiler(), "path(.)");
List mapped = mapper.rewrite(preimage, imagePoint, config);
assertEquals(1, mapped.size());
assertEquals(
@@ -198,7 +198,7 @@ public void testHtmlNoNsBackwardHeadNode() throws ResourceException, SaxonApiExc
new XdmValueResource(GESANG_XML, transform(source, TEXT_WITH_TOC_HTML_XSL, LIBTRACE_XML), PROC);
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeBackwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeBackwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeBackwardMapper(PROC.newXPathCompiler(), "path(.)");
List mapped = mapper.rewrite(preimage, imagePoint, config);
assertEquals(1, mapped.size());
assertEquals(
diff --git a/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeForwardMapper.java b/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeForwardMapper.java
index 87082e5..4681ae1 100644
--- a/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeForwardMapper.java
+++ b/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeForwardMapper.java
@@ -63,7 +63,7 @@ public void testGesangMappedWithIdentity() throws ResourceException, SaxonApiExc
XdmValueResource image = new XdmValueResource(GESANG_XML, transform(source, ID_XSL, LIBTRACE_XML));
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeForwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeForwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeForwardMapper(PROC.newXPathCompiler(), "path(.)");
XPathRefinedByRFC5147CharScheme preimagePoint =
new XPathRefinedByRFC5147CharScheme("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:head[1]", 5);
List mapped = mapper.rewrite(preimage, preimagePoint, CONFIG);
@@ -85,7 +85,7 @@ public void testForwardToMultipleNodes() throws ResourceException, SaxonApiExcep
new XdmValueResource(GESANG_XML, transform(source, TEXT_WITH_TOC_XHTML_XSL, LIBTRACE_XML));
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeForwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeForwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeForwardMapper(PROC.newXPathCompiler(), "path(.)");
List mapped = mapper.rewrite(preimage, preimagePoint, CONFIG);
assertEquals(2, mapped.size());
@@ -121,7 +121,7 @@ public void testForwardToZeroNodes() throws ResourceException, SaxonApiException
new XdmValueResource(GESANG_XML, transform(source, TEXT_WITH_TOC_XHTML_XSL, LIBTRACE_XML));
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeForwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeForwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeForwardMapper(PROC.newXPathCompiler(), "path(.)");
List mapped = mapper.rewrite(preimage, preimagePoint, CONFIG);
assertEquals(0, mapped.size());
}
@@ -137,7 +137,7 @@ public void testHtmlForwardToOneNode() throws ResourceException, SaxonApiExcepti
new XdmValueResource(GESANG_XML, transform(source, TEXT_WITH_TOC_HTML_XSL, LIBTRACE_XML));
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeForwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeForwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeForwardMapper(PROC.newXPathCompiler(), "path(.)");
List mapped = mapper.rewrite(preimage, preimagePoint, CONFIG);
assertEquals(1, mapped.size());
assertEquals(
@@ -157,7 +157,7 @@ public void testHtmlNoNsForwardToOneNode() throws ResourceException, SaxonApiExc
new XdmValueResource(GESANG_XML, transform(source, TEXT_WITH_TOC_HTML_XSL, LIBTRACE_XML));
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeForwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeForwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeForwardMapper(PROC.newXPathCompiler(), "path(.)");
List mapped = mapper.rewrite(preimage, preimagePoint, CONFIG_NO_NS);
assertEquals(1, mapped.size());
assertEquals(
@@ -173,7 +173,7 @@ public void testTextToOneNode() throws ResourceException, SaxonApiException, Sel
XdmValueResource image = new XdmValueResource(GESANG_XML, transform(source, TEXT_XSL, LIBTRACE_XML));
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeForwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeForwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeForwardMapper(PROC.newXPathCompiler(), "path(.)");
XPathRefinedByRFC5147CharScheme preimagePoint =
new XPathRefinedByRFC5147CharScheme("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:head[1]", 5);
List mapped = mapper.rewrite(preimage, preimagePoint, CONFIG);
@@ -193,7 +193,7 @@ public void testTextToOneNodeWithRootOffset() throws ResourceException, SaxonApi
preimage.setImage(image);
// let $ctx:=., $rt:=$ctx/ancestor-or-self::node()[parent::node()[not(parent::node())]] return path($rt)
XPathRefinedByRFC5147CharSchemeForwardMapper mapper = new XPathRefinedByRFC5147CharSchemeForwardMapper(
- "path(ancestor-or-self::node()[ parent::node()[not(parent::node())] ]) ");
+ PROC.newXPathCompiler(), "path(ancestor-or-self::node()[ parent::node()[not(parent::node())] ]) ");
XPathRefinedByRFC5147CharScheme preimagePoint =
new XPathRefinedByRFC5147CharScheme("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:head[1]", 5);
List mapped = mapper.rewrite(preimage, preimagePoint, CONFIG);
diff --git a/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeToTextBackwardMapper.java b/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeToTextBackwardMapper.java
index b54021d..9ed4ec7 100644
--- a/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeToTextBackwardMapper.java
+++ b/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeToTextBackwardMapper.java
@@ -79,7 +79,7 @@ public void testTextToOneNodeWithXPathAndPos5() throws ResourceException, SaxonA
assertEquals(PROC, image.getProcessor());
assertEquals(PROC, preimage.getImage().getProcessor());
XPathRefinedByRFC5147CharSchemeToTextBackwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeToTextBackwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeToTextBackwardMapper(PROC.newXPathCompiler(), "path(.)");
// ("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:head[1]/text()[1]", 5);
RFC5147CharScheme imagePoint = new RFC5147CharScheme(252);
List mapped = mapper.rewrite(preimage, imagePoint, config);
@@ -97,7 +97,7 @@ public void testTextToOneNodeWithXPathAndPos0() throws ResourceException, SaxonA
XdmValueResource image = new XdmValueResource(GESANG_XML, transform(source, TEXT_XSL, LIBTRACE_XML), PROC);
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeToTextBackwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeToTextBackwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeToTextBackwardMapper(PROC.newXPathCompiler(), "path(.)");
RFC5147CharScheme imagePoint = new RFC5147CharScheme(247); // ambivalence!
// ("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:head[1]", 0);
// ("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]", 16);
@@ -117,7 +117,7 @@ public void testTextToOneNodeWithXPathAndPos0WithDeepestConfig()
XdmValueResource image = new XdmValueResource(GESANG_XML, transform(source, TEXT_XSL, LIBTRACE_XML), PROC);
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeToTextBackwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeToTextBackwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeToTextBackwardMapper(PROC.newXPathCompiler(), "path(.)");
RFC5147CharScheme imagePoint = new RFC5147CharScheme(247); // ambivalence!
// ("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:head[1]", 0);
// ("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]", 16);
@@ -137,7 +137,7 @@ public void testTextToOneNodeWithPos0Char() throws ResourceException, SaxonApiEx
XdmValueResource image = new XdmValueResource(GESANG_XML, transform(source, TEXT_XSL, LIBTRACE_XML), PROC);
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeToTextBackwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeToTextBackwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeToTextBackwardMapper(PROC.newXPathCompiler(), "path(.)");
RFC5147CharScheme imagePoint = new RFC5147CharScheme(0);
// ("/*", 0);
List mapped = mapper.rewrite(preimage, imagePoint, config);
@@ -154,7 +154,7 @@ public void testTextToNoneNode() throws ResourceException, SaxonApiException, Se
XdmValueResource image = new XdmValueResource(GESANG_XML, transform(source, NO_HEADER_XSL, LIBTRACE_XML), PROC);
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeToTextBackwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeToTextBackwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeToTextBackwardMapper(PROC.newXPathCompiler(), "path(.)");
RFC5147CharScheme imagePoint = new RFC5147CharScheme(54);
List mapped = mapper.rewrite(preimage, imagePoint, config);
assertEquals(1, mapped.size());
diff --git a/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeToTextForwardMapper.java b/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeToTextForwardMapper.java
index 760647d..e7cfeff 100644
--- a/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeToTextForwardMapper.java
+++ b/core/src/test/java/de/wwu/scdh/annotation/selection/rewriter/TestXPathRefinedByRFC5147CharSchemeToTextForwardMapper.java
@@ -77,7 +77,7 @@ public void testTextToOneNodeWithXPathAndPos5() throws ResourceException, SaxonA
XdmValueResource image = new XdmValueResource(GESANG_XML, transform(source, TEXT_XSL, LIBTRACE_XML));
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeToTextForwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeToTextForwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeToTextForwardMapper(PROC.newXPathCompiler(), "path(.)");
XPathRefinedByRFC5147CharScheme preimagePoint =
new XPathRefinedByRFC5147CharScheme("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:head[1]", 5);
List mapped = mapper.rewrite(preimage, preimagePoint, config);
@@ -95,7 +95,7 @@ public void testTextToOneNodeWithXPathAndPos0() throws ResourceException, SaxonA
XdmValueResource image = new XdmValueResource(GESANG_XML, transform(source, TEXT_XSL, LIBTRACE_XML));
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeToTextForwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeToTextForwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeToTextForwardMapper(PROC.newXPathCompiler(), "path(.)");
XPathRefinedByRFC5147CharScheme preimagePoint =
new XPathRefinedByRFC5147CharScheme("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:head[1]", 0);
List mapped = mapper.rewrite(preimage, preimagePoint, config);
@@ -113,7 +113,7 @@ public void testTextToOneNodeWithPos0Char() throws ResourceException, SaxonApiEx
XdmValueResource image = new XdmValueResource(GESANG_XML, transform(source, TEXT_XSL, LIBTRACE_XML));
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeToTextForwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeToTextForwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeToTextForwardMapper(PROC.newXPathCompiler(), "path(.)");
XPathRefinedByRFC5147CharScheme preimagePoint = new XPathRefinedByRFC5147CharScheme("/*", 0);
List mapped = mapper.rewrite(preimage, preimagePoint, config);
assertEquals(1, mapped.size());
@@ -130,7 +130,7 @@ public void testTextToNoneNode() throws ResourceException, SaxonApiException, Se
XdmValueResource image = new XdmValueResource(GESANG_XML, transform(source, NO_HEADER_XSL, LIBTRACE_XML));
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeToTextForwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeToTextForwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeToTextForwardMapper(PROC.newXPathCompiler(), "path(.)");
XPathRefinedByRFC5147CharScheme preimagePoint =
new XPathRefinedByRFC5147CharScheme("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:head[1]", 5);
List mapped = mapper.rewrite(preimage, preimagePoint, config);
@@ -145,7 +145,7 @@ public void testTextToOptionalNodeWithXPathAndPos6()
XdmValueResource image = new XdmValueResource(GESANG_XML, transform(source, NO_HEADER_XSL, LIBTRACE_XML));
preimage.setImage(image);
XPathRefinedByRFC5147CharSchemeToTextForwardMapper mapper =
- new XPathRefinedByRFC5147CharSchemeToTextForwardMapper("path(.)");
+ new XPathRefinedByRFC5147CharSchemeToTextForwardMapper(PROC.newXPathCompiler(), "path(.)");
XPathRefinedByRFC5147CharScheme preimagePoint =
new XPathRefinedByRFC5147CharScheme("/*:TEI[1]/*:text[1]/*:body[1]/*:lg[1]/*:l[2]/text()[2]", 6);
List mapped = mapper.rewrite(preimage, preimagePoint, config);
diff --git a/core/src/test/java/de/wwu/scdh/annotation/selection/wadm/TestNormalizeAnnotation.java b/core/src/test/java/de/wwu/scdh/annotation/selection/wadm/TestNormalizeAnnotation.java
index 027fda1..ce61909 100644
--- a/core/src/test/java/de/wwu/scdh/annotation/selection/wadm/TestNormalizeAnnotation.java
+++ b/core/src/test/java/de/wwu/scdh/annotation/selection/wadm/TestNormalizeAnnotation.java
@@ -26,6 +26,8 @@
*/
public class TestNormalizeAnnotation {
+ private static final Processor PROC = new Processor();
+
public static final String IRI = "https://docs.org/scdh.span.42.html";
public static final String REWRITE_IRI = "https://docs.org/scdh.span.42.xhtml";
@@ -37,7 +39,7 @@ public class TestNormalizeAnnotation {
public static final URI SPAN_HTML = new File(SAMPLE_DIR, "scdh.span.42.html").toURI();
- private final RewriterFactory rewriterFactory = new NormalizerFactory();
+ private final RewriterFactory rewriterFactory = new NormalizerFactory(PROC.newXPathCompiler());
private RewriterConfig normalizerConfig;
private Model model;
@@ -50,7 +52,7 @@ public class TestNormalizeAnnotation {
public void setupResource() throws URISyntaxException, ResourceException, MalformedURLException {
iri = new URI(IRI);
rewriteIri = new URI(REWRITE_IRI);
- ResourceBuilder resourceBuilder = new ResourceBuilder(new Processor());
+ ResourceBuilder resourceBuilder = new ResourceBuilder(PROC);
try (InputStream inputStream = SPAN_HTML.toURL().openStream()) {
resource =
resourceBuilder.parseResource(iri, inputStream, SPAN_HTML.toString(), ResourceBuilder.Parser.HTML);
diff --git a/core/xslt-package.xml b/core/xslt-package.xml
index cf28f6c..dac3e7c 100644
--- a/core/xslt-package.xml
+++ b/core/xslt-package.xml
@@ -16,7 +16,7 @@
${project.basedir}/src/main/resources/xslt
selene
- **/*.xsl
+ *.xsl
saxon*.xml