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 Carl Hagenmaier <ca...@voxa.com> on 2007/01/26 14:26:19 UTC

cr/lf options

We have some old code that uses XMLSerializer and OutputFormat, which provides the method setLineSeparator(String arg0).  The code has some problems, and I'm trying to replace it with code built on javax.xml.transform.Transformer.  

Unfortunately, I can't see any way to control the line separator.  The archives contain a thread from 2001, which is not encouraging. I'm hopeful that there's been a relevant update.  Any suggestions?

--
Carl Hagenmaier

Re: cr/lf options

Posted by Brian Minchau <mi...@ca.ibm.com>.
Carl,
the classes you refer to, org.apache.xml.serialize.XMLSerializer and
org.apache.xml.serialize.OutputFormat are both from the Xerces project, not
the Xalan project.

However you are asking a question about XSLT and presumably Xalan.  Xalan
has its own serializer. You would have to work at setting the appropriate
properties in order to use a different serializer, so I presume that when
using Xalan you are using the serializer packaged with Xalan.

On the javax.xml.transform.Transformer you will find the method
setOutputProperty(String key, String value). This method is used to
over-ride values of parameters found on the xsl:output element in the
stylesheet that control serialization.  Besides the standard values,
"method", "version",  "encoding" ...  Xalan provides some extension or
non-standard xsl:output properties and one of those, "line-separator" is
the one you are interested in.

See the page
http://xml.apache.org/xalan-j/apidocs/org/apache/xalan/transformer/TransformerImpl.html
  and look for "line-separator".

Note that the API is a standard JAXP API, but the String  values passed for
the key are not standard.


- Brian
- - - - - - - - - - - - - - - - - - - -
Brian Minchau, Ph.D.
XSLT Development, IBM Toronto
e-mail:        minchau@ca.ibm.com



                                                                           
             "Carl Hagenmaier"                                             
             <ca...@voxa.com>                                               
                                                                        To 
             01/26/2007 08:26          <xa...@xml.apache.org>      
             AM                                                         cc 
                                                                           
                                                                   Subject 
                                       cr/lf options                       
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




We have some old code that uses XMLSerializer and OutputFormat, which
provides the method setLineSeparator(String arg0).  The code has some
problems, and I'm trying to replace it with code built on
javax.xml.transform.Transformer.

Unfortunately, I can't see any way to control the line separator.  The
archives contain a thread from 2001, which is not encouraging. I'm hopeful
that there's been a relevant update.  Any suggestions?

--
Carl Hagenmaier


Re: cr/lf options

Posted by Henry Zongaro <zo...@ca.ibm.com>.
Hi, Carl.

"Carl Hagenmaier" <ca...@voxa.com> wrote on 2007-01-26 08:26:19 AM:
> We have some old code that uses XMLSerializer and OutputFormat, 
> which provides the method setLineSeparator(String arg0).  The code 
> has some problems, and I'm trying to replace it with code built on 
> javax.xml.transform.Transformer. 

Xalan-J has a processor-specific line-separator output property that you 
can set on a Transformer object (or specify in a stylesheet).  For 
example,

  Transformer t = TransformerFactory.newInstance().newTransformer();
  t.setOutputProperty("{http://xml.apache.org/xalan}line-separator",
                      "<EOL>");

Any Java string may be supplied as the value of the property, but you'll 
probably want some combination of a carriage return and/or a line feed.

This output property has been supported since Xalan-J 2.7.0.

Thanks,

Henry
------------------------------------------------------------------
Henry Zongaro      XSLT Processors Development
IBM SWS Toronto Lab   T/L 969-6044;  Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com