users@fi.java.net

Re: [Fwd: Re: decoding failure]

From: Tatu Saloranta <cowtowncoder_at_yahoo.com>
Date: Tue, 17 Apr 2007 08:09:18 -0700 (PDT)

--- Paul Sandoz <Paul.Sandoz_at_Sun.COM> wrote:

> Oleksiy Stashok wrote:
> > Hello Ilia,
> >
> > I checked your code.
> > When serializing xml document using
> StreamingSerializer.write(Document),
> > it calls following StAX method sequence:
> >
> > 1) writeStartDocument()
> > 2) writeCharacters("\n")
>
> If you are using an XML StAX implementation, like
> SJSXP (i do not know
> what Woodstox does, the JSR spec is of no help!),
> and write characters
> other than white space characters (or ones that
> conform to comment or PI
> productions) then it will produce a non-well-formed
> XML document and an
> conforming XML parser will barf when parsing the
> document.

Such a case would be non-wellformed doc, and all xml
parsers would thrown an error (unless they can be put
into some kind of fragment mode). So in that way,
sjsxp and woodstox should behave the same.

However, I think what Ilia was saying was that whereas
with Stax, it is possible that all-whitespace
writeCharacters is allowed in prolog/epilog (Woodstox
does allow it; but not if it has non-whitespace -- but
where that's checked depends on configuration),
most/all SAX implementations do NOT allow any
character writing within prolog/epilog. This because
philosophically no character content can be added. Any
white space in there is purely for convenience, and is
not to be considered content.

Given above, it'd make sense to either not call
writeCharacters() at all, or only do that with
stax-backed writers (assuming they all allow this,
which I think is the case).

There was bit of discussion on stax_builders list as
to whether stax parsers are to report such white space
(as SPACE events), and conclusion was that they should
not. This was based on xml specs showing that such
white space really is not even "ignorable white space"
in same sense as white space within elements is (when
content model is not PCDATA or mixed).

Does above make sense?

-+ Tatu +-



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com