writer = new IndentingXMLStreamWriter(factory.createXMLStreamWriter(out, charSet)); } else { writer = factory.createXMLStreamWriter(out, charSet);
/** * Return an XMLStreamWriter which indents the xml * (ideally XMLOutputFactory would support a property which would set this up for us to avoid a dependency * on a com.sun.xml class, but it doesn't for the present time appear to do so) */ public static XMLStreamWriter getIndentingXmlStreamWriter(Writer writer) throws XMLStreamException, IOException { XMLOutputFactory f = XMLOutputFactory.newInstance(); return new IndentingXMLStreamWriter(f.createXMLStreamWriter(writer)); } }
protected AbstractXmlHandler(final Writer dest) throws VeraPDFException { super(); try { this.writer = new IndentingXMLStreamWriter(outputFactory.createXMLStreamWriter(dest)); } catch (XMLStreamException excep) { throw wrapStreamException(excep, "initialising"); //$NON-NLS-1$ } }
protected AbstractXmlHandler(final Writer dest) throws VeraPDFException { super(); try { this.writer = new IndentingXMLStreamWriter(outputFactory.createXMLStreamWriter(dest)); } catch (XMLStreamException excep) { throw wrapStreamException(excep, "initialising"); //$NON-NLS-1$ } }
protected AbstractXmlReportWriter(OutputStream os, OutputStream errorStream) throws XMLStreamException, ParserConfigurationException, SAXException { super(os, errorStream); this.saxParser = SAXParserFactory.newInstance().newSAXParser(); IndentingXMLStreamWriter writer = new IndentingXMLStreamWriter(XMLOutputFactory.newFactory().createXMLStreamWriter(os)); this.writer = writer; this.reportHandler = new ReportParserEventHandler(writer); }
@Override public void output(final BugList bugList, final Writer writer, final CFLintStats stats) throws MarshallerException { try { final XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); XMLStreamWriter xtw = new IndentingXMLStreamWriter(xmlOutputFactory.createXMLStreamWriter(writer)); writeIssues(bugList, xtw, stats); xtw.flush(); } catch (XMLStreamException e) { throw new MarshallerException(e); } }
private static XMLStreamWriter createXmlStreamWriter(ExportOptions options, OutputStream os) throws XMLStreamException { XMLStreamWriter writer = XML_OUTPUT_FACTORY_SUPPLIER.get().createXMLStreamWriter(os, StandardCharsets.UTF_8.toString()); if (options.isIndent()) { IndentingXMLStreamWriter indentingWriter = new IndentingXMLStreamWriter(writer); indentingWriter.setIndent(INDENT); writer = indentingWriter; } return writer; }
@Override public void output(final BugList bugList, final Writer writer, final CFLintStats stats) throws MarshallerException { try { final XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); XMLStreamWriter xtw = new IndentingXMLStreamWriter(xmlOutputFactory.createXMLStreamWriter(writer)); writeIssues(bugList, xtw, stats); xtw.flush(); } catch (XMLStreamException e) { throw new MarshallerException(e); } }
protected AbstractXmlReportWriter(OutputStream os, OutputStream errorStream) throws XMLStreamException, ParserConfigurationException, SAXException { super(os, errorStream); this.saxParser = SAXParserFactory.newInstance().newSAXParser(); IndentingXMLStreamWriter writer = new IndentingXMLStreamWriter(XMLOutputFactory.newFactory().createXMLStreamWriter(os)); this.writer = writer; this.reportHandler = new ReportParserEventHandler(writer); }
private static void writeRDF(Writer stream, DocumentRoot<QName> document) throws XMLStreamException, FactoryConfigurationError, CoreIoException { XMLStreamWriter xmlWriter = new IndentingXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stream)); RdfIo rdfIo = new RdfIo(); rdfIo.createIoWriter(xmlWriter).write(document); xmlWriter.flush(); xmlWriter.close(); }
private static void write(Writer stream, DocumentRoot<QName> document) throws Exception { XMLStreamWriter xmlWriter = new IndentingXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stream)); RdfIo rdfIo = new RdfIo(); // rdfIo.createIoWriter(xmlWriter).write(makeDocument()); rdfIo.createIoWriter(xmlWriter).write(document); xmlWriter.flush(); xmlWriter.close(); }
private static void writeRDF(Writer stream, DocumentRoot<QName> document) throws XMLStreamException, FactoryConfigurationError, CoreIoException { XMLStreamWriter xmlWriter = new IndentingXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stream)); RdfIo rdfIo = new RdfIo(); rdfIo.createIoWriter(xmlWriter).write(document); xmlWriter.flush(); xmlWriter.close(); }
protected XMLStreamWriter filter(XMLStreamWriter writer) { if (indenting) { IndentingXMLStreamWriter indenter = new IndentingXMLStreamWriter(writer); indenter.setNewLine(newLine); indenter.setIndent(indent); writer = indenter; } return writer; }
XMLStreamWriter xtw = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(os)); xtw.writeStartDocument("utf-8","1.0"); xtw.setPrefix(SCH_PREFIX, SCH_NAMESPACE);
private static void copyXML(XMLStreamReader xmlStreamReader, XMLStreamWriter xmlStreamWriter, boolean indent) throws XMLStreamException { try { WhiteSpaceRemovingDelegate xmlStreamReader2 = new XMLUtil.WhiteSpaceRemovingDelegate(xmlStreamReader); XMLStreamWriter xmlStreamWriter2 = xmlStreamWriter; if (indent) { xmlStreamWriter2 = new IndentingXMLStreamWriter(xmlStreamWriter); } XMLStreamUtils.copy(xmlStreamReader2, xmlStreamWriter2); } finally { if (xmlStreamReader != null) { try { xmlStreamReader.close(); } catch (XMLStreamException e) { /* ignore */ } } if (xmlStreamWriter != null) { try { xmlStreamWriter.close(); } catch (XMLStreamException e) { /* ignore */ } } } }
public static void toStream(OutputStream outStream, NormalizedNode<?, ?> node) throws XMLStreamException, IOException { XMLOutputFactory xmlFactory = XMLOutputFactory.newFactory(); xmlFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); XMLStreamWriter xmlWriter = xmlFactory.createXMLStreamWriter(outStream); IndentingXMLStreamWriter indenting = new IndentingXMLStreamWriter(xmlWriter); try(NormalizedNodeStreamWriter streamWriter = XMLStreamNormalizedNodeStreamWriter.createSchemaless( indenting)) { NormalizedNodeWriter nodeWriter = NormalizedNodeWriter.forStreamWriter(streamWriter); nodeWriter.write(node); nodeWriter.flush(); } }
@Override public void writeTo(final NormalizedNodeContext t, final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException, WebApplicationException { final InstanceIdentifierContext<?> pathContext = t.getInstanceIdentifierContext(); if (t.getData() == null) { return; } XMLStreamWriter xmlWriter; try { xmlWriter = XML_FACTORY.createXMLStreamWriter(entityStream); if (t.getWriterParameters().isPrettyPrint()) { xmlWriter = new IndentingXMLStreamWriter(xmlWriter); } } catch (final XMLStreamException e) { throw new IllegalStateException(e); } catch (final FactoryConfigurationError e) { throw new IllegalStateException(e); } NormalizedNode<?, ?> data = t.getData(); SchemaPath schemaPath = pathContext.getSchemaNode().getPath(); writeNormalizedNode(xmlWriter, schemaPath, pathContext, data, t.getWriterParameters().getDepth()); }
/** * Method write * * @param writer * @param model */ public void write(Writer writer, Model model) throws java.io.IOException, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); boolean supportWindowsLineEndings = false; if ( factory.isPropertySupported( "com.ctc.wstx.outputEscapeCr" ) ) { factory.setProperty( "com.ctc.wstx.outputEscapeCr", Boolean.FALSE ); supportWindowsLineEndings = true; } if ( factory.isPropertySupported( "org.codehaus.stax2.automaticEmptyElements" ) ) { factory.setProperty( "org.codehaus.stax2.automaticEmptyElements", Boolean.FALSE ); } IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); if ( supportWindowsLineEndings ) { serializer.setNewLine( serializer.getLineSeparator() ); } serializer.writeStartDocument( model.getModelEncoding(), "1.0" ); writeModel( model, "project", serializer ); serializer.writeEndDocument(); } //-- void write(Writer, Model)
/** * Method write * * @param writer * @param userDatabase */ public void write(Writer writer, UserDatabase userDatabase) throws java.io.IOException, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); boolean supportWindowsLineEndings = false; if ( factory.isPropertySupported( "com.ctc.wstx.outputEscapeCr" ) ) { factory.setProperty( "com.ctc.wstx.outputEscapeCr", Boolean.FALSE ); supportWindowsLineEndings = true; } if ( factory.isPropertySupported( "org.codehaus.stax2.automaticEmptyElements" ) ) { factory.setProperty( "org.codehaus.stax2.automaticEmptyElements", Boolean.FALSE ); } IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); if ( supportWindowsLineEndings ) { serializer.setNewLine( serializer.getLineSeparator() ); } serializer.writeStartDocument( userDatabase.getModelEncoding(), "1.0" ); writeUserDatabase( userDatabase, "userDatabase", serializer ); serializer.writeEndDocument(); } //-- void write(Writer, UserDatabase)
/** * Method write * * @param writer * @param model */ public void write(Writer writer, Model model) throws java.io.IOException, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); boolean supportWindowsLineEndings = false; if ( factory.isPropertySupported( "com.ctc.wstx.outputEscapeCr" ) ) { factory.setProperty( "com.ctc.wstx.outputEscapeCr", Boolean.FALSE ); supportWindowsLineEndings = true; } if ( factory.isPropertySupported( "org.codehaus.stax2.automaticEmptyElements" ) ) { factory.setProperty( "org.codehaus.stax2.automaticEmptyElements", Boolean.FALSE ); } IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); if ( supportWindowsLineEndings ) { serializer.setNewLine( serializer.getLineSeparator() ); } serializer.writeStartDocument( model.getModelEncoding(), "1.0" ); writeModel( model, "project", serializer ); serializer.writeEndDocument(); } //-- void write(Writer, Model)