public boolean shouldRun() throws SaxonApiException { String testExpr = ((When) step).getTest(); XdmNode doc = null; NamespaceBinding nsbinding = new NamespaceBinding(runtime, step.getNode()); Hashtable<QName,RuntimeValue> globals = parent.getInScopeOptions(); ReadablePipe reader = inputs.get("#xpath-context").firstElement(); doc = reader.read(); if (reader.moreDocuments() || inputs.get("#xpath-context").size() > 1) { throw XProcException.dynamicError(5); } // Surround testExpr with "boolean()" to force the EBV. Vector<XdmItem> results = evaluateXPath(doc, nsbinding.getNamespaceBindings(), "boolean(" + testExpr + ")", globals); if (results.size() != 1) { throw new XProcException("Attempt to compute EBV in p:when did not return a singleton!?"); } XdmAtomicValue value = (XdmAtomicValue) results.get(0); return value.getBooleanValue(); }
@Override public void run() throws SaxonApiException { try { XProcMessageListenerHelper.openStep(runtime, parent, BigDecimal.ONE); } catch (Throwable e) { throw handleException(e); } try { super.run(); } finally { runtime.getMessageListener().closeStep(); } } }
XWhen newstep = new XWhen(runtime, substep, this); newstep.instantiate(substep); } else if (XProcConstants.p_otherwise.equals(substep.getType())) { XOtherwise newstep = new XOtherwise(runtime, substep, this);
if (step instanceof XWhen) { XWhen when = (XWhen) step; if (when.shouldRun()) { xstep = when; break;
XWhen newstep = new XWhen(runtime, substep, this); newstep.instantiate(substep); } else if (XProcConstants.p_otherwise.equals(substep.getType())) { XOtherwise newstep = new XOtherwise(runtime, substep, this);
if (step instanceof XWhen) { XWhen when = (XWhen) step; if (when.shouldRun()) { xstep = when; break;
public boolean shouldRun() throws SaxonApiException { String testExpr = ((When) step).getTest(); XdmNode doc = null; NamespaceBinding nsbinding = new NamespaceBinding(runtime, step.getNode()); Hashtable<QName,RuntimeValue> globals = parent.getInScopeOptions(); ReadablePipe reader = inputs.get("#xpath-context").firstElement(); doc = reader.read(); if (reader.moreDocuments() || inputs.get("#xpath-context").size() > 1) { throw XProcException.dynamicError(5); } // Surround testExpr with "boolean()" to force the EBV. Vector<XdmItem> results = evaluateXPath(doc, nsbinding.getNamespaceBindings(), "boolean(" + testExpr + ")", globals); if (results.size() != 1) { throw new XProcException("Attempt to compute EBV in p:when did not return a singleton!?"); } XdmAtomicValue value = (XdmAtomicValue) results.get(0); return value.getBooleanValue(); }