The conversion of a LF to a space in attribute values is actually in the specification. See XML 1.0.
 
Sam
-----Original Message-----
From: Greg Matthews [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 14, 2001 7:25 PM
To: [EMAIL PROTECTED]
Subject: carriage return in attribute not preserved


dear all,
 
how do i preserve carriage returns inside attributes?
 
if i have some xml as a String,
 
<x a="hello
world"/>
 
then when i parse it and then serialize it like follows the carriage return is lost, and i end up with
 
<x a="hello world"/>
 
  org.apache.xerces.parsers.DOMParser parser = new org.apache.xerces.parsers.DOMParser();
  InputSource is = new InputSource( new ByteArrayInputStream( s.getBytes()));
  parser.parse( is );
  Element n2 = parser.getDocument().getDocumentElement();
  OutputFormat of = new OutputFormat();
  of.setOmitXMLDeclaration( true );
  of.setIndenting( false );
  org.apache.xml.serialize.XMLSerializer ser = new XMLSerializer( System.out, of );
  ser.asDocumentHandler();
  ser.setOutputFormat( of );
  ser.serialize( n2 );
what do i need to do to keep the original format?
 
thanks,
greg.

Reply via email to