Re: asymmetry between serialzier and parser inwriting XMLDecl

Aleksander Slominski <[email protected]>
Newsgroups gmane.text.xml.xmlpull.devel
Message-ID <[email protected]>
Elliotte Rusty Harold wrote:

> >in XmlSerializer writing XMLDecl (<?xml version='1.0' ...?>) is supported
> >by startDocument() method however XmlPullParser will report XMLDecl as PI.
> >and each rountrip will add second <?xml as it thinks it is just another PI
> >(unless there is special code to detect that PI is really XMLDecl ...)
> >
> >if we use isWhitespace() (or isEmptyElementTag()) to signalize that PI
> >is not a real PI and should be ignored but instead interpreted as
> >XML declaration ...
> >
>
> I don't see how this would fix it. The XML declaration is not a
> processing instruction. XmlPullParser should not report it as one.
> Overloading isWhiteSpace() or isEmptyElementTag() with a completely
> different meaning that has nothing to do with white space or
> empty-element tags just confuses the issue  further, and is totally
> non-obvious.
>
> Either XmlPullParser should not report the XML declaration at all, or
> it should have a different token type to represent this construct.

hi,

i agree with you. however we want to keep backward compatibility for time
being and then have 2.x version that will fix all problems that were identified.

so i would think about it as a gradual improvement - the other possibility
introducing new event will break compatibility and that is what we really
want to avoid. anyway this affects only nextToken() method and only
for PROCESSING_INSTRUCTION event and i think in typical
80/20 cases next() should be used.

thanks,

alek
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.