/** * Append an arbitrary item (node or atomic value) to the output */ public void append(Item item, int locationId, int copyNamespaces) throws XPathException { if (item instanceof AtomicValue) { if (previousAtomic) { characters(" ", locationId, 0); } characters(item.getStringValueCS(), locationId, 0); previousAtomic = true; } else if (((NodeInfo)item).getNodeKind() == Type.DOCUMENT) { SequenceIterator iter = ((NodeInfo)item).iterateAxis(Axis.CHILD); while (true) { Item it = iter.next(); if (it == null) break; append(it, locationId, copyNamespaces); } previousAtomic = false; } else { ((NodeInfo)item).copy(this, copyNamespaces, true, locationId); previousAtomic = false; } }
break; tr.append(item, 0, NodeInfo.ALL_NAMESPACES);
/** * Serialize a sequence to a given result * @param iterator the sequence to be serialized * @param config the Saxon Configuration * @param result the destination to receive the output * @param outputProperties the serialization properties to be used. The requested properties are * not validated. * @throws XPathException * @since 9.0 */ public static void serializeSequence( SequenceIterator iterator, Configuration config, Result result, Properties outputProperties) throws XPathException { SerializerFactory sf = config.getSerializerFactory(); PipelineConfiguration pipe = config.makePipelineConfiguration(); Receiver receiver = sf.getReceiver(result, pipe, outputProperties); TreeReceiver tr = new TreeReceiver(receiver); tr.open(); while (true) { Item item = iterator.next(); if (item == null) { break; } tr.append(item, 0, NodeInfo.ALL_NAMESPACES); } tr.close(); }
tree.startDocument(0); for (XdmItem item : value) { tree.append(item.getUnderlyingValue(), ExplicitLocation.UNKNOWN_LOCATION, ReceiverOptions.ALL_NAMESPACES);
/** * Append an arbitrary item (node or atomic value) to the output */ public void append(Item item, int locationId, int copyNamespaces) throws XPathException { if (item instanceof AtomicValue) { if (previousAtomic) { characters(" ", locationId, 0); } characters(item.getStringValueCS(), locationId, 0); previousAtomic = true; } else if (((NodeInfo)item).getNodeKind() == Type.DOCUMENT) { startDocument(0); // needed to ensure that illegal namespaces or attributes in the content are caught SequenceIterator iter = ((NodeInfo)item).iterateAxis(Axis.CHILD); while (true) { Item it = iter.next(); if (it == null) break; append(it, locationId, copyNamespaces); } previousAtomic = false; endDocument(); } else { ((NodeInfo)item).copy(this, copyNamespaces, true, locationId); previousAtomic = false; } }
tree.startDocument(0); for (XdmItem item : value) { tree.append(item.getUnderlyingValue(), ExplicitLocation.UNKNOWN_LOCATION, ReceiverOptions.ALL_NAMESPACES);
public static void writeXdmValue(Processor proc, Vector<XdmValue> values, Destination destination, URI baseURI) throws SaxonApiException { try { Configuration config = proc.getUnderlyingConfiguration(); PipelineConfiguration pipeConfig = config.makePipelineConfiguration(); Receiver out = destination.getReceiver(config); TreeReceiver tree = new TreeReceiver(out); tree.setPipelineConfiguration(pipeConfig); if (baseURI != null) { tree.setSystemId(baseURI.toASCIIString()); } tree.open(); tree.startDocument(0); for (XdmValue value : values) { for (XdmItem item : (Iterable<XdmItem>) value) { tree.append((Item) item.getUnderlyingValue(), VoidLocation.instance(), NodeInfo.ALL_NAMESPACES); } } tree.endDocument(); tree.close(); } catch (XPathException err) { throw new SaxonApiException(err); } }
public static void writeXdmValue(XProcRuntime runtime, XdmItem node, Destination destination, URI baseURI) throws SaxonApiException { try { Processor proc = runtime.getProcessor(); Configuration config = proc.getUnderlyingConfiguration(); PipelineConfiguration pipeConfig = config.makePipelineConfiguration(); Receiver out = destination.getReceiver(config); TreeReceiver tree = new TreeReceiver(out); tree.setPipelineConfiguration(pipeConfig); if (baseURI != null) { tree.setSystemId(baseURI.toASCIIString()); } tree.open(); tree.startDocument(0); tree.append((Item) node.getUnderlyingValue(), VoidLocation.instance(), NodeInfo.ALL_NAMESPACES); tree.endDocument(); tree.close(); } catch (XPathException err) { throw new SaxonApiException(err); } }
public static void writeXdmValue(XProcRuntime runtime, XdmItem node, Destination destination, URI baseURI) throws SaxonApiException { try { Processor proc = runtime.getProcessor(); Configuration config = proc.getUnderlyingConfiguration(); PipelineConfiguration pipeConfig = config.makePipelineConfiguration(); Receiver out = destination.getReceiver(config); TreeReceiver tree = new TreeReceiver(out); tree.setPipelineConfiguration(pipeConfig); if (baseURI != null) { tree.setSystemId(baseURI.toASCIIString()); } tree.open(); tree.startDocument(0); Location locationId; { if (baseURI != null && config.isLineNumbering()) { int lineNumber = node instanceof XdmNode ? ((XdmNode)node).getLineNumber() : -1; if (lineNumber > 0) locationId = new LineNumberLocation(baseURI.toASCIIString(), lineNumber); else locationId = VoidLocation.instance(); } else locationId = VoidLocation.instance(); } tree.append((Item) node.getUnderlyingValue(), locationId, NodeInfo.ALL_NAMESPACES); tree.endDocument(); tree.close(); } catch (XPathException err) { throw new SaxonApiException(err); } }
tree.append((Item) item.getUnderlyingValue(), locationId, NodeInfo.ALL_NAMESPACES);