Jörg Hohwiller wrote:
Hi there,


Brian Minchau wrote:
Hi Stanimir.

The Xalan
serializer doesn't know about whether the serialized XML will
be used in the the future as an external general parsed
entity and included in yet another XML file.

It is possible that the XML will be included next to a text node that
is not all whitespace and the extra whitespace that we inject after the
XML header would be included next to non-whitespace
text and become part of that text node, modifying it.

Extra whitespace added for indentation is done in ignorable locations,
but this particular one (just after the header) might not be ignored.

Added indentation or extra whitespace before the document element
is not always correct, so Xalan doesn't do it.

There is no Xalan specific option to control this behavior.

- Brian


1. Could you please give an example or a link to the
XML-specification to point out why a newline after
XML-declation or at the end of the file should make the XML illegal. I am NOT talking about your problems
to implement this properly, but why
<?xml ....?>^n
<root>...</root>^n
should be illegal!?!?
Brian didn't say it would make the result "illegal." He simply said that it would modify the content of the result inappropriately. The processor generates a external general parsed entity, and a newline between the XML declaration would introduce whitespace into the content of the entity.


2. Having a newline after XML-declaration as well
as at the end of the file is a common need that
JAXP users have. I can NOT accept your point
saying that this is generally NOT supported because
it could cause some trouble you may have implementing this.
I find the tone of your post to be offensive. No one on this list owes you anything in particular, and I suggest you be more polite in future posts.

This has a large impact after everybody has to eat this
when just using a plain JDK. It is a lot worse if people
start adding newlines manually to OutputStream,
because this will cause real trouble with encodings, especially
if the encoding is NOT 8-bit-wise (e.g. UTF-16) and a newlines
get broken because hackers of such workaround do NOT think
of such problems.
Any XML parser that requires a newline between the XML declaration and the root element, or after the root element, is non-conforming and should be fixed.


Please provide a solution here.
You can always post-process the document and add the new line characters.

Dave

Reply via email to