void writeformattedItem(XdmItem item, ProcessContext context, OutputStream out) throws TransformerFactoryConfigurationError, TransformerException, IOException { if (item.isAtomicValue()) { out.write(item.getStringValue().getBytes(UTF8)); } else { // item is an XdmNode XdmNode node = (XdmNode) item; switch (node.getNodeKind()) { case DOCUMENT: case ELEMENT: Transformer transformer = TransformerFactory.newInstance().newTransformer(); final Properties props = getTransformerProperties(context); transformer.setOutputProperties(props); transformer.transform(node.asSource(), new StreamResult(out)); break; default: out.write(node.getStringValue().getBytes(UTF8)); } } }
/** * Writes the content of an XdmValue sequence to a string. Each item in the * sequence is either an atomic value or a node. * * @param value A value in the XDM data model. * @return A String representing the content of the sequence. * * @see * <a target="_blank" href="http://www.saxonica.com/html/documentation/javadoc/net/sf/saxon/s9api/XdmValue.html">Saxon * API: XdmValue</a> * @see * <a target="_blank" href="http://www.w3.org/TR/xpath-datamodel/">XQuery * 1.0 and XPath 2.0 Data Model (XDM) (Second Edition)</a> */ public static String writeXdmValueToString(XdmValue value) { StringBuilder str = new StringBuilder(); for (XdmItem item : value) { if (item.isAtomicValue()) { str.append(item.getStringValue()); } else { XdmNode node = (XdmNode) item; str.append(node.getNodeName()).append(": "); str.append(node.getStringValue()); } str.append('\n'); } return str.toString(); }
void writeformattedItem(XdmItem item, ProcessContext context, OutputStream out) throws TransformerFactoryConfigurationError, TransformerException, IOException { if (item.isAtomicValue()) { out.write(item.getStringValue().getBytes(UTF8)); } else { // item is an XdmNode XdmNode node = (XdmNode) item; switch (node.getNodeKind()) { case DOCUMENT: case ELEMENT: Transformer transformer = TransformerFactory.newInstance().newTransformer(); final Properties props = getTransformerProperties(context); transformer.setOutputProperties(props); transformer.transform(node.asSource(), new StreamResult(out)); break; default: out.write(node.getStringValue().getBytes(UTF8)); } } }
item.getUnderlyingValue().getClass().getName(), item }); if (item.isAtomicValue()) { LOG.debug("Ignoring atomic value in result sequence: {}", item); continue;
item.getUnderlyingValue().getClass().getName(), item }); if (item.isAtomicValue()) { LOG.debug("Ignoring atomic value in result sequence: {}", item); continue;
protected void addResult(NamedList<Object> xpathResults, XdmItem item) throws SaxonApiException { if (item.isAtomicValue()) {
/** * Get an ItemType representing the type of a supplied XdmItem. If the supplied item is * an atomic value, the returned ItemType will reflect the most specific atomic type of the * item. If the supplied item is a node, the returned item type will reflect the node kind, * and if the node has a name, then its name. It will not reflect the type annotation. * * @param item the supplied item whose type is required * @return the type of the supplied item */ public ItemType getItemType(XdmItem item) { if (item.isAtomicValue()) { AtomicValue value = (AtomicValue) item.getUnderlyingValue(); AtomicType type = value.getItemType(); return new ConstructedItemType(type, processor); } else { NodeInfo node = (NodeInfo) item.getUnderlyingValue(); int kind = node.getNodeKind(); if (node.getLocalPart().isEmpty()) { return new ConstructedItemType(NodeKindTest.makeNodeKindTest(kind), processor); } else { return new ConstructedItemType(new SameNameTest(node), processor); } } }
Vector<XdmItem> items = parse(node, value); for (XdmItem item : items) { if (item.isAtomicValue()) { matcher.addText(item.getStringValue()); } else {
/** * Get an ItemType representing the type of a supplied XdmItem. If the supplied item is * an atomic value, the returned ItemType will reflect the most specific atomic type of the * item. If the supplied item is a node, the returned item type will reflect the node kind, * and if the node has a name, then its name. It will not reflect the type annotation. * * @param item the supplied item whose type is required * @return the type of the supplied item */ public ItemType getItemType(XdmItem item) { if (item.isAtomicValue()) { AtomicValue value = (AtomicValue) item.getUnderlyingValue(); AtomicType type = value.getItemType(); return new ConstructedItemType(type, processor); } else { NodeInfo node = (NodeInfo) item.getUnderlyingValue(); int kind = node.getNodeKind(); if (node.getLocalPart().isEmpty()) { return new ConstructedItemType(NodeKindTest.makeNodeKindTest(kind), processor); } else { return new ConstructedItemType(new SameNameTest(node), processor); } } }
while (values.hasNext()) { XdmItem item = values.next(); if (element != null || item.isAtomicValue()) { throw XProcException.dynamicError(9); if (item.isAtomicValue()) { value += item.getStringValue(); } else {
Vector<XdmItem> items = parse(node, value); for (XdmItem item : items) { if (item.isAtomicValue()) { matcher.addText(item.getStringValue()); } else {
continue; if (count == 1 && !xpathResult.isAtomicValue()) { net.sf.saxon.s9api.QName name = ((XdmNode)xpathResult).getNodeName(); if (name != null && name.getNamespaceURI().equals(EXPATH_HTTP_NS) &&
@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); } } } } }
if (xdmvalue.size() == 1) { XdmItem item = xdmvalue.itemAt(0); if (item.isAtomicValue()) { atom = (XdmAtomicValue) item; while (iter.hasNext()) { XdmItem next = iter.next(); QName type = next.isAtomicValue() ? ((XdmAtomicValue) next).getPrimitiveTypeName() : null; if (next.isAtomicValue()) { treeWriter.addAttribute(_value, next.getStringValue()); treeWriter.startContent();
if (xdmvalue.size() == 1) { XdmItem item = xdmvalue.itemAt(0); if (item.isAtomicValue()) { atom = (XdmAtomicValue) item; while (iter.hasNext()) { XdmItem next = iter.next(); QName type = next.isAtomicValue() ? ((XdmAtomicValue) next).getPrimitiveTypeName() : null; if (next.isAtomicValue()) { treeWriter.addAttribute(_value, next.getStringValue()); treeWriter.startContent();
/** * Get an ItemType representing the type of a supplied XdmItem. If the supplied item is * an atomic value, the returned ItemType will reflect the most specific atomic type of the * item. If the supplied item is a node, the returned item type will reflect the node kind, * and if the node has a name, then its name. It will not reflect the type annotation. * @param item the supplied item whose type is required * @return the type of the supplied item */ public ItemType getItemType(XdmItem item) { Configuration config = processor.getUnderlyingConfiguration(); if (item.isAtomicValue()) { AtomicValue value = (AtomicValue)item.getUnderlyingValue(); AtomicType type = (AtomicType)value.getItemType(config.getTypeHierarchy()); return new ItemType(type, processor); } else { NodeInfo node = (NodeInfo)item.getUnderlyingValue(); int kind = node.getNodeKind(); int fp = node.getFingerprint(); if (fp == -1) { return new ItemType(NodeKindTest.makeNodeKindTest(kind), processor); } else { return new ItemType(new NameTest(kind, fp, config.getNamePool()), processor); } } }
static String getLabel(XdmNode n) { String label = n.getAttributeValue(LABEL_QNAME); if (label == null) { XdmNode value = (XdmNode) n.axisIterator(Axis.CHILD).next(); XdmItem childItem = null; try { childItem = value.axisIterator(Axis.CHILD).next(); } catch (Exception e) { // Not an error } if (childItem == null) { XdmSequenceIterator it = value.axisIterator(Axis.ATTRIBUTE); if (it.hasNext()) { label = it.next().getStringValue(); } else { label = ""; } } else if (childItem.isAtomicValue()) { label = childItem.getStringValue(); } else if (childItem instanceof XdmNode) { XdmNode n2 = (XdmNode) childItem; if (n2.getNodeKind() == XdmNodeKind.ELEMENT) { label = "<" + n2.getNodeName().toString() + ">"; } else { label = n2.toString(); } } } return label; }
static String getLabel(XdmNode n) { String label = n.getAttributeValue(LABEL_QNAME); if (label == null) { XdmNode value = (XdmNode) n.axisIterator(Axis.CHILD).next(); XdmItem childItem = null; try { childItem = value.axisIterator(Axis.CHILD).next(); } catch (Exception e) { // Not an error } if (childItem == null) { XdmSequenceIterator it = value.axisIterator(Axis.ATTRIBUTE); if (it.hasNext()) { label = it.next().getStringValue(); } else { label = ""; } } else if (childItem.isAtomicValue()) { label = childItem.getStringValue(); } else if (childItem instanceof XdmNode) { XdmNode n2 = (XdmNode) childItem; if (n2.getNodeKind() == XdmNodeKind.ELEMENT) { label = "<" + n2.getNodeName().toString() + ">"; } else { label = n2.toString(); } } } return label; }
XdmNode node = null; if (item.isAtomicValue()) { if (runtime.getAllowTextResults()) { TreeWriter tree = new TreeWriter(runtime);
XdmNode node = null; if (item.isAtomicValue()) { if (runtime.getAllowTextResults()) { TreeWriter tree = new TreeWriter(runtime);