public TeeOutputter(Receiver seq1, Receiver seq2) { if (seq1 instanceof SequenceReceiver) { this.seq1 = (SequenceReceiver)seq1; } else { this.seq1 = new TreeReceiver(seq1); } if (seq2 instanceof SequenceReceiver) { this.seq2 = (SequenceReceiver)seq2; } else { this.seq2 = new TreeReceiver(seq2); } }
public TeeOutputter(Receiver seq1, Receiver seq2) { if (seq1 instanceof SequenceReceiver) { this.seq1 = (SequenceReceiver)seq1; } else { this.seq1 = new TreeReceiver(seq1); } if (seq2 instanceof SequenceReceiver) { this.seq2 = (SequenceReceiver)seq2; } else { this.seq2 = new TreeReceiver(seq2); } }
public SequenceReceiver makeSequenceNormalizer(Receiver receiver, Properties properties) { String method = properties.getProperty(OutputKeys.METHOD); if ("json".equals(method) || "adaptive".equals(method)) { return receiver instanceof SequenceReceiver ? (SequenceReceiver)receiver : new TreeReceiver(receiver); } else { PipelineConfiguration pipe = receiver.getPipelineConfiguration(); SequenceReceiver result; String separator = properties.getProperty(SaxonOutputKeys.ITEM_SEPARATOR); if (separator == null || "#absent".equals(separator)) { result = new SequenceNormalizerWithSpaceSeparator(receiver); } else { result = new SequenceNormalizerWithItemSeparator(receiver, separator); } result.setPipelineConfiguration(pipe); return result; } }
public SequenceReceiver makeSequenceNormalizer(Receiver receiver, Properties properties) { String method = properties.getProperty(OutputKeys.METHOD); if ("json".equals(method) || "adaptive".equals(method)) { return receiver instanceof SequenceReceiver ? (SequenceReceiver)receiver : new TreeReceiver(receiver); } else { PipelineConfiguration pipe = receiver.getPipelineConfiguration(); SequenceReceiver result; String separator = properties.getProperty(SaxonOutputKeys.ITEM_SEPARATOR); if (separator == null || "#absent".equals(separator)) { result = new SequenceNormalizerWithSpaceSeparator(receiver); } else { result = new SequenceNormalizerWithItemSeparator(receiver, separator); } result.setPipelineConfiguration(pipe); return result; } }
TinyBuilder builder = new TinyBuilder(); builder.setPipelineConfiguration(pipe); TreeReceiver receiver = new TreeReceiver(builder); builder.setPipelineConfiguration(pipe); EventIteratorToReceiver.copy(sub, receiver);
TinyBuilder builder = new TinyBuilder(); builder.setPipelineConfiguration(pipe); TreeReceiver receiver = new TreeReceiver(builder); builder.setPipelineConfiguration(pipe); EventIteratorToReceiver.copy(sub, receiver);
@Override public void setResult(Result result) throws IllegalArgumentException { try { PipelineConfiguration pipe = controller.makePipelineConfiguration(); setPipelineConfiguration(pipe); Receiver out = controller.getConfiguration().getSerializerFactory().getReceiver( result, new SerializationProperties(), pipe); Receiver in = controller.getStreamingReceiver(controller.getInitialMode(), new TreeReceiver(out)); setReceiver(in); } catch (XPathException e) { throw new IllegalArgumentException(e); } }
@Override public void setResult(Result result) throws IllegalArgumentException { try { PipelineConfiguration pipe = controller.makePipelineConfiguration(); setPipelineConfiguration(pipe); Receiver out = controller.getConfiguration().getSerializerFactory().getReceiver( result, new SerializationProperties(), pipe); Receiver in = controller.getStreamingReceiver(controller.getInitialMode(), new TreeReceiver(out)); setReceiver(in); } catch (XPathException e) { throw new IllegalArgumentException(e); } }
/** * Create a serialization pipeline to implement a user-defined output method. This method is protected * so that it can be customized in a user-written SerializerFactory * * @param method the name of the user-defined output method, as a QName in Clark format * (that is "{uri}local"). * @param props the serialization properties * @param pipe the pipeline configuration information * @return a Receiver acting as the entry point to the serialization pipeline * @throws XPathException if a failure occurs */ protected SequenceReceiver createUserDefinedOutputMethod(String method, Properties props, PipelineConfiguration pipe) throws XPathException { Receiver userReceiver;// See if this output method is recognized by the Configuration userReceiver = pipe.getConfiguration().makeEmitter(method, props); userReceiver.setPipelineConfiguration(pipe); if (userReceiver instanceof ContentHandlerProxy && "yes".equals(props.getProperty(SaxonOutputKeys.SUPPLY_SOURCE_LOCATOR))) { if (pipe.getConfiguration().isCompileWithTracing() && pipe.getController() != null) { pipe.getController().addTraceListener( ((ContentHandlerProxy) userReceiver).getTraceListener()); } else { throw new XPathException( "Cannot use saxon:supply-source-locator unless tracing was enabled at compile time", SaxonErrorCode.SXSE0002); } } return userReceiver instanceof SequenceReceiver ? (SequenceReceiver)userReceiver : new TreeReceiver(userReceiver); }
/** * Create a serialization pipeline to implement a user-defined output method. This method is protected * so that it can be customized in a user-written SerializerFactory * * @param method the name of the user-defined output method, as a QName in Clark format * (that is "{uri}local"). * @param props the serialization properties * @param pipe the pipeline configuration information * @return a Receiver acting as the entry point to the serialization pipeline * @throws XPathException if a failure occurs */ protected SequenceReceiver createUserDefinedOutputMethod(String method, Properties props, PipelineConfiguration pipe) throws XPathException { Receiver userReceiver;// See if this output method is recognized by the Configuration userReceiver = pipe.getConfiguration().makeEmitter(method, props); userReceiver.setPipelineConfiguration(pipe); if (userReceiver instanceof ContentHandlerProxy && "yes".equals(props.getProperty(SaxonOutputKeys.SUPPLY_SOURCE_LOCATOR))) { if (pipe.getConfiguration().isCompileWithTracing() && pipe.getController() != null) { pipe.getController().addTraceListener( ((ContentHandlerProxy) userReceiver).getTraceListener()); } else { throw new XPathException( "Cannot use saxon:supply-source-locator unless tracing was enabled at compile time", SaxonErrorCode.SXSE0002); } } return userReceiver instanceof SequenceReceiver ? (SequenceReceiver)userReceiver : new TreeReceiver(userReceiver); }
Receiver emitter = controller.getMessageEmitter(); SequenceReceiver rec = new TreeReceiver(emitter); rec = new AttributeMasker(rec);
/** * 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(); }
TreeReceiver tr = new TreeReceiver(receiver); tr.open(); while (true) {
receiver = new TreeReceiver(receiver);
Receiver out = destination.getReceiver(config.makePipelineConfiguration(), config.obtainDefaultSerializationProperties()); out = new NamespaceReducer(out); TreeReceiver tree = new TreeReceiver(out); tree.open(); tree.startDocument(0);
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); } }
private void sendPullEventSource(PullEventSource source, Receiver receiver, ParseOptions options) throws XPathException { boolean xInclude = options.isXIncludeAware(); if (xInclude) { throw new XPathException("XInclude processing is not supported with a pull parser"); } receiver = makeValidator(receiver, source.getSystemId(), options); receiver.open(); EventIterator provider = source.getEventIterator(); if (provider instanceof LocationProvider) { pipe.setLocationProvider((LocationProvider)provider); } receiver.setPipelineConfiguration(pipe); SequenceReceiver out = receiver instanceof SequenceReceiver ? ((SequenceReceiver)receiver) : new TreeReceiver(receiver); EventIteratorToReceiver.copy(provider, out); receiver.close(); }
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); } }
TreeReceiver tree = new TreeReceiver(out); tree.setPipelineConfiguration(pipeConfig); if (baseURI != null) {