You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by db...@qis.net on 2005/04/20 17:17:35 UTC

Can't get identer working

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));


Re: Can't get identer working

Posted by db...@qis.net.
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 <jg...@alumni.princeton.edu>:

> IIRC, the indent-amount property name has "xalan" in it somewhere.
> Jeff
> 
> dbrosius@qis.net 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));
> >
> >
> >
> >  
> >
> 




Re: Can't get identer working

Posted by Jeff Greif <jg...@alumni.princeton.edu>.
IIRC, the indent-amount property name has "xalan" in it somewhere.
Jeff

dbrosius@qis.net 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));
>
>
>
>  
>