This seems to work:

    private void emitXML(Document xsd, OutputStream xsdStream)
        throws TransformerException
    {
        TransformerFactory tf = TransformerFactory.newInstance();
        tf.setAttribute("indent-number", new Integer(4));
        Transformer t = tf.newTransformer();
        t.setOutputProperty(OutputKeys.INDENT, "yes");
        t.setOutputProperty(OutputKeys.METHOD, "xml");
        t.setOutputProperty(OutputKeys.MEDIA_TYPE, "text/xml");

        t.transform(new DOMSource(xsd), new StreamResult(new
OutputStreamWriter(xsdStream)));
    }



Quoting Jeff Greif <[EMAIL PROTECTED]>:

> IIRC, the indent-amount property name has "xalan" in it somewhere.
> Jeff
> 
> [EMAIL PROTECTED] wrote:
> 
> >I'm sure this is an idiot error on my part, but when transforming, i can't
> seem
> >to get indenting to happen (although new lines are added appropriately)
> >I am using xerces dom3 parser.
> >
> >Here's my code:
> >
> >TransformerFactory tf = TransformerFactory.newInstance();
> >Transformer t = tf.newTransformer();
> >t.setOutputProperty(OutputKeys.INDENT, "yes");
> >t.setOutputProperty(OutputKeys.METHOD, "xml");
> >t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount";, "4");
> >t.setOutputProperty(OutputKeys.MEDIA_TYPE, "text/xml");
> >
> >t.transform(new DOMSource(xsd), new StreamResult(xsdStream));
> >
> >
> >
> >  
> >
> 



Reply via email to