public void run() throws SaxonApiException { super.run(); RuntimeValue match = getOption(_match); replace = getOption(_replace); for (String prefix : replace.getNamespaceBindings().keySet()) { rns.put(prefix, replace.getNamespaceBindings().get(prefix)); } matcher = new ProcessMatch(runtime, this); matcher.match(source.read(), match); result.write(matcher.getResult()); }
public void run() throws SaxonApiException { super.run(); RuntimeValue match = getOption(_match); replace = getOption(_replace); for (String prefix : replace.getNamespaceBindings().keySet()) { rns.put(prefix, replace.getNamespaceBindings().get(prefix)); } matcher = new ProcessMatch(runtime, this); matcher.match(source.read(), match); result.write(matcher.getResult()); }
Predicate<XdmNode> parseOption(RuntimeValue option) throws XPathException { if (!option.getString().equals("/*")) { XPathExpression matcher = SaxonHelper.compileExpression(option.getString(), option.getNamespaceBindings(), config); return n -> n.getNodeKind() == XdmNodeKind.ELEMENT && SaxonHelper.evaluateBoolean(matcher, n); } else return n -> false; }
: SaxonHelper.compileExpression(splitBefore.getString(), splitBefore.getNamespaceBindings(), configuration); final XPathExpression splitAfterMatcher = splitAfter.getString().isEmpty() ? null : SaxonHelper.compileExpression(splitAfter.getString(), splitAfter.getNamespaceBindings(), configuration); final List<SplitPoint> result = new ArrayList<SplitPoint>(); new Consumer<XdmNode>() {
private XdmItem computeGroup(XdmNode node) { try { XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler(); xcomp.setBaseURI(step.getNode().getBaseURI()); for (String prefix : groupAdjacent.getNamespaceBindings().keySet()) { xcomp.declareNamespace(prefix, groupAdjacent.getNamespaceBindings().get(prefix)); } XPathExecutable xexec = xcomp.compile(groupAdjacent.getString()); XPathSelector selector = xexec.load(); selector.setContextItem(node); Iterator<XdmItem> values = selector.iterator(); if (values.hasNext()) { return values.next(); } else { return null; } } catch (SaxonApiException sae) { throw new XProcException(sae); } } }
private XdmItem computeGroup(XdmNode node) { try { XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler(); xcomp.setBaseURI(step.getNode().getBaseURI()); for (String prefix : groupAdjacent.getNamespaceBindings().keySet()) { xcomp.declareNamespace(prefix, groupAdjacent.getNamespaceBindings().get(prefix)); } XPathExecutable xexec = xcomp.compile(groupAdjacent.getString()); XPathSelector selector = xexec.load(); selector.setContextItem(node); Iterator<XdmItem> values = selector.iterator(); if (values.hasNext()) { return values.next(); } else { return null; } } catch (SaxonApiException sae) { throw new XProcException(sae); } } }
private String computedLabel(XdmNode node) throws SaxonApiException { XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler(); xcomp.setBaseURI(step.getNode().getBaseURI()); // Make sure any namespace bindings in-scope for the label are available for the expression for (String prefix : label.getNamespaceBindings().keySet()) { xcomp.declareNamespace(prefix, label.getNamespaceBindings().get(prefix)); } xcomp.declareVariable(p_index); XPathExecutable xexec = xcomp.compile(label.getString()); XPathSelector selector = xexec.load(); selector.setVariable(p_index,new XdmAtomicValue(count++)); selector.setContextItem(node); Iterator<XdmItem> values = selector.iterator(); XdmItem item = values.next(); return item.getStringValue(); } }
private String computedLabel(XdmNode node) throws SaxonApiException { XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler(); xcomp.setBaseURI(step.getNode().getBaseURI()); // Make sure any namespace bindings in-scope for the label are available for the expression for (String prefix : label.getNamespaceBindings().keySet()) { xcomp.declareNamespace(prefix, label.getNamespaceBindings().get(prefix)); } xcomp.declareVariable(p_index); XPathExecutable xexec = xcomp.compile(label.getString()); XPathSelector selector = xexec.load(); selector.setVariable(p_index,new XdmAtomicValue(count++)); selector.setContextItem(node); Iterator<XdmItem> values = selector.iterator(); XdmItem item = values.next(); return item.getStringValue(); } }
public int count(XdmNode doc, RuntimeValue match, boolean deep) { count = 0; try { XPathEvaluator xeval = new XPathEvaluator(saxonConfig); NamespaceResolver resolver = new MatchingNamespaceResolver(match.getNamespaceBindings()); xeval.getStaticContext().setNamespaceResolver(resolver); matcher = xeval.createPattern(match.getString()); traverse(doc, deep); } catch (XProcException e) { throw e; } catch (Exception e) { throw new XProcException(e); } return count; }
public int count(XdmNode doc, RuntimeValue match, boolean deep) { count = 0; try { XPathEvaluator xeval = new XPathEvaluator(saxonConfig); NamespaceResolver resolver = new MatchingNamespaceResolver(match.getNamespaceBindings()); xeval.getStaticContext().setNamespaceResolver(resolver); matcher = xeval.createPattern(match.getString()); traverse(doc, deep); } catch (XProcException e) { throw e; } catch (Exception e) { throw new XProcException(e); } return count; }
localBindings = nsv.getNamespaceBindings(); } else if (nsbinding.getXPath() != null) { try { nsBindings = val.getNamespaceBindings();
localBindings = nsv.getNamespaceBindings(); } else if (nsbinding.getXPath() != null) { try { nsBindings = val.getNamespaceBindings();
NamespaceResolver resolver = new MatchingNamespaceResolver(match.getNamespaceBindings()); xeval.getStaticContext().setNamespaceResolver(resolver);
NamespaceResolver resolver = new MatchingNamespaceResolver(match.getNamespaceBindings()); xeval.getStaticContext().setNamespaceResolver(resolver);
xcomp.setBaseURI(step.getNode().getBaseURI()); for (String prefix : test.getNamespaceBindings().keySet()) { xcomp.declareNamespace(prefix, test.getNamespaceBindings().get(prefix));
xcomp.setBaseURI(step.getNode().getBaseURI()); for (String prefix : test.getNamespaceBindings().keySet()) { xcomp.declareNamespace(prefix, test.getNamespaceBindings().get(prefix));
xcomp.setBaseURI(step.getNode().getBaseURI()); for (String prefix : groupAdjacent.getNamespaceBindings().keySet()) { xcomp.declareNamespace(prefix, groupAdjacent.getNamespaceBindings().get(prefix));
xcomp.setBaseURI(step.getNode().getBaseURI()); for (String prefix : groupAdjacent.getNamespaceBindings().keySet()) { xcomp.declareNamespace(prefix, groupAdjacent.getNamespaceBindings().get(prefix));