[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Classpathx-xml] Aelfred2 problem with whitespace

From: Musachy Barroso
Subject: Re: [Classpathx-xml] Aelfred2 problem with whitespace
Date: Sat, 7 Aug 2004 08:31:01 +0000

I checked it out, the thing is that the spaces are getting reported as

I got this from the SAX faq (

The ContentHandler.characters() callback is missing data!

    Please read the JavaDoc for this method. A parser may split text
into any number of separate chunks, and some characters may be
reported using ignorableWhitespace() instead of this callback.

    If you want all the text inside an element, you need to collect
the text from the various characters callbacks into a buffer. Only
when you see the endElement event can you be sure that you have seen
all the text, and some of it may really "belong" to child elements.


On Fri, 06 Aug 2004 12:20:35 +0200, Maarten Coene
<address@hidden> wrote:
> Hi,
> thanks for fixing my previous problems, however I'm having a new
> problem: the Aelfred2 parser removes the whitespace in my element content.
> For instance, if I parse the following document:
>     <root>&lt;head&gt; &amp; &lt;body&gt;</root>
> the spaces before and after the "&amp;" are lost!!
> Here is some code that illustrates the problem:
>     public void testWhitespace() throws Exception {
>         String xml = "<root>&lt;head&gt; &amp; &lt;body&gt;</root>";
>         InputStream in = new ByteArrayInputStream(xml.getBytes());
>         SAXParserFactory factory = new JAXPFactory();
>         factory.newSAXParser().parse(in, new DefaultHandler2() {
>             public void characters(char[] ch, int start, int end) {
>                 System.out.print(new String(ch, start, end));
>             }
>         });
>     }
> This is the output I'm getting:
> <head>&<body>
> but I was expecting this output:
> <head> & <body>
> regards,
> Maarten
> _______________________________________________
> Classpathx-xml mailing list
> address@hidden

"Hey you! Would you help me to carry the stone?"
                                                         Pink Floyd

reply via email to

[Prev in Thread] Current Thread [Next in Thread]