xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
- To: Dick H <dick AT wt.net>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] XML whitespace in text
- Date: Mon, 28 Apr 2003 15:39:10 -0400
I was surprised to see XOM remove newlines in my text:
<element>There was a new line here:
2nd line.
</element>
After using Builder and Xerces 2.4 Builder, I get
<element>There was a new line here: 2nd line.
</element>
My reading of XML spec says that any text within an element (but outside tags) is significant, including new lines.
Whats up?
Did you turn on any of the pretty printing options in the Serializer? (They're all off by default.) If so, that's what's happening. If not, see if you can come up with a simple test case. There might be a bug.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo AT metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| Processing XML with Java (Addison-Wesley, 2002) |
| http://www.cafeconleche.org/books/xmljava |
| http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+
From dick AT wt.net Mon Apr 28 15:57:42 2003Return-Path: <dick AT wt.net>
Delivered-To: xom-interest AT lists.ibiblio.org
Received: from host.globalsecureserver.com (host.globalsecureserver.com
[209.239.37.116])
by happyhouse.metalab.unc.edu (Postfix) with ESMTP id 5147420025
for <xom-interest AT lists.ibiblio.org>;
Mon, 28 Apr 2003 15:57:42 -0400 (EDT)
Received: from wt.net (dpcbw096162.direcpc.com [65.88.96.162])
h3SJvdE02776
for <xom-interest AT lists.ibiblio.org>; Mon, 28 Apr 2003 15:57:40 -0400
Message-ID: <3EAD874C.9010905 AT wt.net>
Date: Mon, 28 Apr 2003 14:55:56 -0500
From: Dick H <dick AT wt.net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;
rv:1.4a) Gecko/20030401
X-Accept-Language: en,pdf
MIME-Version: 1.0
To: xom-interest AT lists.ibiblio.org
Subject: [XOM-interest] XML whitespace in text
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-BeenThere: xom-interest AT lists.ibiblio.org
X-Mailman-Version: 2.1.1
Precedence: list
List-Id: <xom-interest.lists.ibiblio.org>
List-Unsubscribe: <http://lists.ibiblio.org/mailman/listinfo/xom-interest>,
<mailto:xom-interest-request AT lists.ibiblio.org?subject=unsubscribe>
List-Archive: <https://lists.ibiblio.org/sympa/arc/xom-interest>
List-Post: <mailto:xom-interest AT lists.ibiblio.org>
List-Help: <mailto:sympa AT lists.ibiblio.org?subject=HELP>
List-Subscribe: <http://lists.ibiblio.org/mailman/listinfo/xom-interest>,
<mailto:xom-interest-request AT lists.ibiblio.org?subject=subscribe>
X-List-Received-Date: Mon, 28 Apr 2003 19:57:42 -0000
Yes, example:
public static void main( String[] args )
throws IOException,
ValidityException,
ParseException,
SAXException
{
XMLReader myReader = XMLReaderFactory.createXMLReader(
"org.apache.xerces.parsers.SAXParser");
Builder b = new Builder( myReader, false );
String txt =
"<?xml version='1.0' encoding='UTF-8'?>\n"+
"<element>This is a first line.\n"+
"And here is a second line</element>";
Document d = b.build( new StringReader(txt) );
Serializer serializer = new Serializer( System.out );
// serializer.setIndent(2);
serializer.write(d);
}
If just the setIndent() is called on the Serializer, then the problem occurs. So you have identified when the problem can happen.
However, one could certainly make an argument that the pretty printing should be limited to the XML markup and not the content.
See here FYI:
http://xmlsoft.org/messages/0404.html
Thank you for your support and fine work!
-
[XOM-interest] XML whitespace in text,
Dick H, 04/28/2003
- Re: [XOM-interest] XML whitespace in text, Elliotte Rusty Harold, 04/28/2003
- <Possible follow-up(s)>
- Re: [XOM-interest] XML whitespace in text, Elliotte Rusty Harold, 04/28/2003
- Re: [XOM-interest] XML whitespace in text, Elliotte Rusty Harold, 04/29/2003
- Re: [XOM-interest] XML whitespace in text, Elliotte Rusty Harold, 04/29/2003
Archive powered by MHonArc 2.6.24.