Java Code Examples for net.sf.saxon.s9api.XdmNode#getNodeKind()
The following examples show how to use
net.sf.saxon.s9api.XdmNode#getNodeKind() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EvaluateXQuery.java From localization_nifi with Apache License 2.0 | 6 votes |
void writeformattedItem(XdmItem item, ProcessContext context, OutputStream out) throws TransformerConfigurationException, 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)); } } }
Example 2
Source File: EvaluateXQuery.java From nifi with Apache License 2.0 | 6 votes |
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)); } } }
Example 3
Source File: ConfigurationLoader.java From validator with Apache License 2.0 | 5 votes |
private static XdmNode findRoot(final XdmNode doc) { for (final XdmNode node : doc.children()) { if (node.getNodeKind() == XdmNodeKind.ELEMENT) { return node; } } throw new IllegalArgumentException("Kein root element gefunden"); }
Example 4
Source File: TECore.java From teamengine with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: XQueryBuilder.java From kite with Apache License 2.0 | 5 votes |
private boolean addRecordValues(XdmNode node, Axis axis, XdmNodeKind nodeTest, Record record) { boolean isEmpty = true; XdmSequenceIterator iter = node.axisIterator(axis); while (iter.hasNext()) { XdmNode child = (XdmNode) iter.next(); if (child.getNodeKind() == nodeTest) { String strValue = child.getStringValue(); if (strValue.length() > 0) { record.put(child.getNodeName().getLocalName(), strValue); isEmpty = false; } } } return !isEmpty; }