Re: [xml] strange behaviour of SAX characters callback



Thanks Daniel,

But how can I determine that sequence of "character" callbacks
relates to the same element? Is it right to assume that all
"character" callbacks between "enterElemen" and "exitElement"
callbacks relate to the same element? Is there another solution?

//Vladimir

Daniel Veillard wrote:

On Tue, Sep 17, 2002 at 11:35:36AM +0100, Vladimir F. wrote:
Hi Guys,

I'm new subsriber to this list and want to address the
question about using SAX.

So, there is callback "characters" and I'm trying to use
it to get content of the element like:

<mm7:TransactionID
xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0";
env:mustUnderstand="1">
    vas00001-sub
</mm7:TransactionID>

But I noticed that "characters" callback is called
twice for content "vas00001-sub". One call gets me content
like "\r\n<n-spaces>vas00001-sub..." another just
"\r\n...".

If I remove "\r\n" sequence (which is after "vas0001-sub")
this callback is called just once as it was expected.

How can I force this callback to be called just once for
my elements (independent of the number of spaces, new_lines, etc.
in the content).

  Sorry, you can't ... You have to assume that you may get multiple
characters() callback, it's an optimization related to end of line character
normalization, and also  because I don't want to grow a possibly infinite
buffer in the parser when operating in SAX mode.

Daniel

--
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/


This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain 
proprietary material, confidential information and/or be subject to legal privilege.  It should not be 
copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please 
promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.



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