/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
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); } }
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(); }