/** * 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.close(); destination.closeAndNotify();
tree.close(); destination.closeAndNotify();
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.close(); } catch (XPathException err) { throw new SaxonApiException(err);