public void store(OutputStream ostream) throws IOException { logger.trace("Attempt to write file: " + uri); serializer.setOutputStream(ostream); try { S9apiUtils.serialize(runtime, doc, serializer); } catch (SaxonApiException e) { throw new IOException(e); } } });
/** * Create a serializer initialised to use the default output parameters defined in the stylesheet. * These serialization parameters can be overridden by use of * {@link Serializer#setOutputProperty(Serializer.Property, String)}. * * @param stream the output stream to which the serializer will write * @since 9.7.0.1 */ public Serializer newSerializer(OutputStream stream) { Serializer serializer = newSerializer(); serializer.setOutputStream(stream); return serializer; }
/** * Create a Serializer initialized to write to a given OutputStream. * <p>Closing the output stream after use is the responsibility of the caller.</p> * * @param stream The OutputStream to which the Serializer will write * @return a new Serializer * @since 9.3 */ /*@NotNull*/ public Serializer newSerializer(OutputStream stream) { Serializer s = new Serializer(this); s.setOutputStream(stream); return s; }
/** * Create a serializer initialised to use the default output parameters defined in the stylesheet. * These serialization parameters can be overridden by use of * {@link Serializer#setOutputProperty(Serializer.Property, String)}. * * @param stream the output stream to which the serializer will write * @since 9.7.0.1 */ public Serializer newSerializer(OutputStream stream) { Serializer serializer = newSerializer(); serializer.setOutputStream(stream); return serializer; }
public void store(OutputStream ostream) throws IOException { logger.trace("Attempt to write file: " + uri); serializer.setOutputStream(ostream); try { S9apiUtils.serialize(runtime, doc, serializer); } catch (SaxonApiException e) { throw new IOException(e); } } });
public void store(OutputStream outstr) throws IOException { if (method == CompressionMethod.GZIP) { GZIPOutputStream gzout = new GZIPOutputStream(outstr); outstr = gzout; } serializer.setOutputStream(outstr); try { S9apiUtils.serialize(runtime, doc, serializer); } catch (SaxonApiException e) { throw new IOException(e); } } });
public void store(OutputStream outstr) throws IOException { if (method == CompressionMethod.GZIP) { GZIPOutputStream gzout = new GZIPOutputStream(outstr); outstr = gzout; } serializer.setOutputStream(outstr); try { S9apiUtils.serialize(runtime, doc, serializer); } catch (SaxonApiException e) { throw new IOException(e); } } });
/** * Create a Serializer initialized to write to a given OutputStream. * <p>Closing the output stream after use is the responsibility of the caller.</p> * * @param stream The OutputStream to which the Serializer will write * @return a new Serializer * @since 9.3 */ /*@NotNull*/ public Serializer newSerializer(OutputStream stream) { Serializer s = new Serializer(this); s.setOutputStream(stream); return s; }
private Serializer serializeToFile(File file) throws FileNotFoundException { Serializer serializer = processor.newSerializer(); serializer.setOutputStream(new FileOutputStream(file)); serializer.setCloseOnCompletion(true); return serializer; }
public static InputSource xdmToInputSource(XProcRuntime runtime, XdmNode node) throws SaxonApiException { ByteArrayOutputStream out = new ByteArrayOutputStream(); Serializer serializer = runtime.getProcessor().newSerializer(); serializer.setOutputStream(out); serialize(runtime, node, serializer); InputSource isource = new InputSource(new ByteArrayInputStream(out.toByteArray())); if (node.getBaseURI() != null) { isource.setSystemId(node.getBaseURI().toASCIIString()); } return isource; }
public static InputSource xdmToInputSource(XProcRuntime runtime, XdmNode node) throws SaxonApiException { ByteArrayOutputStream out = new ByteArrayOutputStream(); Serializer serializer = runtime.getProcessor().newSerializer(); serializer.setOutputStream(out); serialize(runtime, node, serializer); InputSource isource = new InputSource(new ByteArrayInputStream(out.toByteArray())); if (node.getBaseURI() != null) { isource.setSystemId(node.getBaseURI().toASCIIString()); } return isource; }
private byte[] textContent(final XdmNode doc) { Serializer serializer = makeSerializer(); serializer.setOutputProperty(Serializer.Property.METHOD, "text"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); serializer.setOutputStream(baos); try { S9apiUtils.serialize(runtime, doc, serializer); } catch (SaxonApiException e) { throw new XProcException(e); } return baos.toByteArray(); }
private byte[] XmlContent(final XdmNode doc) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { try { Serializer serializer = makeSerializer(); serializer.setOutputStream(baos); S9apiUtils.serialize(runtime, doc, serializer); } catch (SaxonApiException e) { throw new XProcException(e); } finally { baos.close(); } } catch (IOException e) { throw new XProcException(e); } return baos.toByteArray(); }
public void storeXML(FileToZip file, XdmNode doc, OutputStream out) throws SaxonApiException { Serializer serializer = makeSerializer(file.getOptions()); serializer.setOutputStream(out); S9apiUtils.serialize(runtime, doc, serializer); }
public void storeXML(FileToZip file, XdmNode doc, OutputStream out) throws SaxonApiException { Serializer serializer = makeSerializer(file.getOptions()); serializer.setOutputStream(out); S9apiUtils.serialize(runtime, doc, serializer); }
public String serializeAsXML(XdmNode node) { try { Serializer serializer = runtime.getProcessor().newSerializer(); serializer.setOutputProperty(Serializer.Property.BYTE_ORDER_MARK, "no"); serializer.setOutputProperty(Serializer.Property.ENCODING, "utf-8"); serializer.setOutputProperty(Serializer.Property.INDENT, "yes"); serializer.setOutputProperty(Serializer.Property.METHOD, "xml"); serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes"); ByteArrayOutputStream os = new ByteArrayOutputStream(); serializer.setOutputStream(os); S9apiUtils.serialize(runtime, node, serializer); String result = os.toString(); return result; } catch (SaxonApiException sae) { logger.warn("Failed to serialize node: " + node); logger.debug(sae.getMessage(), sae); return ""; } }
/** Retrieves the output for a given xslt transformer. * @param xsltTransformer the {@link XsltTransformer} that will receive the output * @return the output as a {@link ByteArrayOutputStream} */ public ByteArrayOutputStream getOutput(final XsltTransformer xsltTransformer) { Serializer serializer = serializerFactory.createSerializer(); serializer.setOutputProperty(Serializer.Property.METHOD, "xml"); serializer.setOutputProperty(Serializer.Property.INDENT, "no"); ByteArrayOutputStream output = byteArrayOutputStreamFactory.createByteArrayOutputStream(); serializer.setOutputStream(output); xsltTransformer.setDestination(serializer); return output; }
public void run() throws SaxonApiException { super.run(); XsltCompiler compiler = runtime.getProcessor().newXsltCompiler(); XsltExecutable exec = compiler.compile(prettyPrint.asSource()); XsltTransformer transformer = exec.load(); transformer.setInitialContextNode(source.read()); ByteArrayOutputStream stream = new ByteArrayOutputStream(); Serializer serializer = runtime.getProcessor().newSerializer(); serializer.setOutputProperty(Serializer.Property.ENCODING, "utf-8"); serializer.setOutputProperty(Serializer.Property.INDENT, "yes"); serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes"); serializer.setOutputProperty(Serializer.Property.METHOD, "xml"); serializer.setOutputStream(stream); transformer.setDestination(serializer); transformer.transform(); XdmNode output = runtime.parse(new InputSource(new ByteArrayInputStream(stream.toByteArray()))); result.write(output); } }
private static void storeXML(XProcRuntime runtime, XdmNode doc, OutputStream stream) { try { try { Serializer serializer = runtime.getProcessor().newSerializer(); serializer.setOutputProperty(Serializer.Property.ENCODING, "utf-8"); serializer.setOutputProperty(Serializer.Property.INDENT, "no"); serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes"); serializer.setOutputProperty(Serializer.Property.METHOD, "xml"); serializer.setOutputStream(stream); S9apiUtils.serialize(runtime, doc, serializer); } finally { stream.close(); } } catch (IOException ioe) { throw new XProcException("Failed to serialize as XML: " + doc, ioe); } catch (SaxonApiException sae) { throw new XProcException("Failed to serialize as XML: " + doc, sae); } }
private static void storeXML(XProcRuntime runtime, XdmNode doc, OutputStream stream) { try { try { Serializer serializer = runtime.getProcessor().newSerializer(); serializer.setOutputProperty(Serializer.Property.ENCODING, "utf-8"); serializer.setOutputProperty(Serializer.Property.INDENT, "no"); serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes"); serializer.setOutputProperty(Serializer.Property.METHOD, "xml"); serializer.setOutputStream(stream); S9apiUtils.serialize(runtime, doc, serializer); } finally { stream.close(); } } catch (IOException ioe) { throw new XProcException("Failed to serialize as XML: " + doc, ioe); } catch (SaxonApiException sae) { throw new XProcException("Failed to serialize as XML: " + doc, sae); } }