public StaxSerializer(XMLStreamWriter writer, boolean indenting) { if(indenting) writer = new IndentingXMLStreamWriter(writer); this.out = writer; }
FileOutputStream fileOutputStream = new FileOutputStream(outXmlFile); XMLStreamWriter defaultWriter = factory.createXMLStreamWriter(fileOutputStream, encoding); IndentingXMLStreamWriter writer = new IndentingXMLStreamWriter(defaultWriter); writer.setIndentStep(" "); try { writer.writeStartDocument(encoding, "1.0"); if (stylesheet != null) { writer.writeProcessingInstruction("xml-stylesheet", "type='text/xsl' href='" + stylesheet + "'"); writer.writeCharacters("\n"); } writer.writeStartElement(TAG_ROOT); writer.writeAttribute(TAG_OBJECT_TYPE, rootObject.getClass().getSimpleName()); ... writer.writeEndElement(); writer.writeEndDocument(); } finally { writer.flush(); writer.close(); fileOutputStream.close(); }
private void onEndElement() throws XMLStreamException { depth--; if (state == SEEN_ELEMENT) { super.writeCharacters("\n"); doIndent(); } state = stateStack.pop(); }
private void init(Result result, boolean indent) { try { XMLOutputFactory factory = XMLOutputFactory.newFactory(); writer = factory.createXMLStreamWriter(result); if (indent) { IndentingXMLStreamWriter indenter = new IndentingXMLStreamWriter(writer); indenter.setIndentStep(" "); writer = indenter; } } catch (XMLStreamException exception) { throw new XmlException("Can't create XML writer", exception); } }
public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException { onEmptyElement(); super.writeEmptyElement(prefix, localName, namespaceURI); }
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException { onStartElement(); super.writeStartElement(namespaceURI, localName); }
/** * Set the current indent step. * * @param indentStep The new indent step (0 or less for no * indentation). * @see #getIndentStep() * * @deprecated * Should use the version that takes string. */ public void setIndentStep(int indentStep) { StringBuilder s = new StringBuilder(); for (; indentStep > 0; indentStep--) s.append(' '); setIndentStep(s.toString()); }
public void writeEndElement() throws XMLStreamException { onEndElement(); super.writeEndElement(); }
public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException { onEmptyElement(); super.writeEmptyElement(namespaceURI, localName); }
public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException { onStartElement(); super.writeStartElement(prefix, localName, namespaceURI); }
/** * Set the current indent step. * * @param indentStep The new indent step (0 or less for no * indentation). * @see #getIndentStep() * * @deprecated * Should use the version that takes string. */ public void setIndentStep(int indentStep) { StringBuilder s = new StringBuilder(); for (; indentStep > 0; indentStep--) s.append(' '); setIndentStep(s.toString()); }
public void writeEndElement() throws XMLStreamException { onEndElement(); super.writeEndElement(); }
public StaxSerializer(XMLStreamWriter writer, boolean indenting) { if(indenting) writer = new IndentingXMLStreamWriter(writer); this.out = writer; }
private void onStartElement() throws XMLStreamException { stateStack.push(SEEN_ELEMENT); state = SEEN_NOTHING; if (depth > 0) { super.writeCharacters("\n"); } doIndent(); depth++; }
public void writeEmptyElement(String localName) throws XMLStreamException { onEmptyElement(); super.writeEmptyElement(localName); }
public void writeStartElement(String localName) throws XMLStreamException { onStartElement(); super.writeStartElement(localName); }
/** * Set the current indent step. * * @param indentStep The new indent step (0 or less for no * indentation). * @see #getIndentStep() * * @deprecated * Should use the version that takes string. */ public void setIndentStep(int indentStep) { StringBuilder s = new StringBuilder(); for (; indentStep > 0; indentStep--) s.append(' '); setIndentStep(s.toString()); }
public void writeEndElement() throws XMLStreamException { onEndElement(); super.writeEndElement(); }
public StaxSerializer(XMLStreamWriter writer, boolean indenting) { if(indenting) writer = new IndentingXMLStreamWriter(writer); this.out = writer; }
private void onStartElement() throws XMLStreamException { stateStack.push(SEEN_ELEMENT); state = SEEN_NOTHING; if (depth > 0) { super.writeCharacters("\n"); } doIndent(); depth++; }