Permalink
Browse files

Refactor XPath compilation to fix issue #143.

  • Loading branch information...
ndw committed Apr 25, 2014
1 parent a85cda6 commit eb361d9ab036d444608ba92964d1bc1fc407f86c
Showing with 15 additions and 15 deletions.
  1. +15 −15 src/com/xmlcalabash/library/SplitSequence.java
@@ -92,6 +92,21 @@ public void run() throws SaxonApiException {
DocumentSequenceIterator xsi = new DocumentSequenceIterator(); // See below
xsi.setLast(count);
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
for (String prefix : test.getNamespaceBindings().keySet()) {
xcomp.declareNamespace(prefix, test.getNamespaceBindings().get(prefix));
}
XPathExecutable xexec = xcomp.compile(test.getString());
// From Michael Kay: http://markmail.org/message/vkb2vaq2miylgndu
//
// Underneath the s9api XPathExecutable is a net.sf.saxon.sxpath.XPathExpression.
XPathExpression xexpr = xexec.getUnderlyingExpression();
int pos = 0;
while (source.moreDocuments()) {
XdmNode doc = source.read();
@@ -100,21 +115,6 @@ public void run() throws SaxonApiException {
Item item = null;
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
for (String prefix : test.getNamespaceBindings().keySet()) {
xcomp.declareNamespace(prefix, test.getNamespaceBindings().get(prefix));
}
XPathExecutable xexec = xcomp.compile(test.getString());
// From Michael Kay: http://markmail.org/message/vkb2vaq2miylgndu
//
// Underneath the s9api XPathExecutable is a net.sf.saxon.sxpath.XPathExpression.
XPathExpression xexpr = xexec.getUnderlyingExpression();
// Call createDynamicContext() on this to get an XPathDynamicContext object;
XPathDynamicContext xdc = xexpr.createDynamicContext(doc.getUnderlyingNode());

0 comments on commit eb361d9

Please sign in to comment.