xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henry Zongaro <zong...@ca.ibm.com>
Subject Re: Format attributes in XML tags
Date Thu, 13 May 2004 13:19:20 GMT
Hi, Johannes.

Johannes Lebek <joh.lebek@gmx.de> wrote on 2004-05-13 06:47:08 AM:
> I'd like Xalan to format my XML output file. The requirement is to put 
> each attribute in a new line. An example:
> The following tag:
> <my-tag attr1="ahf" attr2="kjfr" attr3="dfhjdhf" attr4="jddjfh"/>
> ...should be formatted like this:
> <my-tag
>    attr1="ahf"
>    attr2="kjfr"
>    attr3="dfhjdhf"
>    attr4="jddjfh"/>
> Is there a property I can set to force Xalan to format the output like I 

> want it to?
> Thanks for your suggestions,

     For the most part, the XSLT language, and the Xalan processors 
specifically, do not provide options to perform those kinds of pretty 
printing.  There are exceptions of course:  the indent and 
cdata-section-elements attributes of xsl:output.

     The only way to do what you'd like with a stylesheet is to "manually" 
format your tags through the use of the disable-output-escaping attribute 
of xsl:value-of and xsl:text.  In the case of the Xalan-Java processors, 
you could also send your result to a SAXResult object that contains a 
ContentHandler.  You would have to code the ContentHandler to take the SAX 
events and format the result the way you require.


Henry Zongaro      Xalan development
IBM SWS Toronto Lab   T/L 969-6044;  Phone +1 905 413-6044

View raw message