public boolean hasFocus(Collection<File> tests) { for (File test : tests) { if (test.exists()) { try { XdmNode node = new XdmNode( processor.getUnderlyingConfiguration().buildDocument(new StreamSource(test))); if (((XdmAtomicValue)xpathCompiler.evaluateSingle("exists(//scenario[@focus])", node)).getBooleanValue()) return true; } catch (SaxonApiException e) { } catch (XPathException e) { } } } return false; }
XdmNode node = new XdmNode( processor.getUnderlyingConfiguration().buildDocument(new StreamSource(test))); if (((XdmAtomicValue)xpathCompiler.evaluateSingle("exists(//scenario[@focus])", node)).getBooleanValue()) focusTests.add(testName); } catch (SaxonApiException e) {
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(); }
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(); }
public static boolean xpathEqual(Processor proc, XdmItem a, XdmItem b) { try { XPathCompiler c = proc.newXPathCompiler(); c.declareVariable(vara); c.declareVariable(varb); XPathExecutable xexec = c.compile("$vara = $varb"); XPathSelector selector = xexec.load(); selector.setVariable(vara,a); selector.setVariable(varb,b); Iterator<XdmItem> values = selector.iterator(); XdmAtomicValue item = (XdmAtomicValue) values.next(); boolean same = item.getBooleanValue(); return same; } catch (SaxonApiException sae) { return false; } }
public static boolean xpathEqual(Processor proc, XdmItem a, XdmItem b) { try { XPathCompiler c = proc.newXPathCompiler(); c.declareVariable(vara); c.declareVariable(varb); XPathExecutable xexec = c.compile("$vara = $varb"); XPathSelector selector = xexec.load(); selector.setVariable(vara,a); selector.setVariable(varb,b); Iterator<XdmItem> values = selector.iterator(); XdmAtomicValue item = (XdmAtomicValue) values.next(); boolean same = item.getBooleanValue(); return same; } catch (SaxonApiException sae) { return false; } }
boolean same = item.getBooleanValue(); if (same) { result.success();
boolean same = item.getBooleanValue(); if (same) { result.success();
changed = !item.getBooleanValue();
changed = !item.getBooleanValue();
((OMElement) destination).setText(String.valueOf(((XdmAtomicValue) xdmItem).getBooleanValue())); } else if (ItemType.DOUBLE == itemType) { ((OMElement) destination).setText(String.valueOf(((XdmAtomicValue) xdmItem).getDoubleValue()));
@Override public void collect(int docId) throws IOException { Document doc = this.context.reader().document(docId); BytesRef binaryValue = doc.getBinaryValue(LUX_XML_FIELD_NAME); if (binaryValue != null) { byte[] bytes = binaryValue.bytes; // Assuming the lux_xml field is configured to use the Lux TinyBinary xml format in the // Lux update chain if (bytes.length > 4 && bytes[0] == 'T' && bytes[1] == 'I' && bytes[2] == 'N') { TinyBinary tb = new TinyBinary(bytes, TinyBinaryField.UTF8); XdmNode node = new XdmNode(tb.getTinyDocument(config)); try { selector.setContextItem(node); XdmItem result = selector.evaluateSingle(); if (result != null && result.size() > 0 && !(result.isAtomicValue() && !((XdmAtomicValue) result).getBooleanValue())) { super.collect(docId); } } catch (SaxonApiException e) { throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Unable to evaluate xpath: " + xpath, e); } } } } }
boolean same = item.getBooleanValue(); if (!same && getOption(_fail_if_not_equal,false)) { throw XProcException.stepError(19);
boolean same = item.getBooleanValue(); if (!same && getOption(_fail_if_not_equal,false)) { throw XProcException.stepError(19);