On Sun, 21 Sep 2008, Owen Jacobson wrote:
On Sep 21, 4:47 am, "Mike Schilling" <mscottschill...@hotmail.com>
wrote:
Owen Jacobson wrote:
First - it is completely legal for an XML file to begin with
whitespace, comments, processing instructions, or a tag - so (in the
absence of an example) I have to suppose that your RSS parser is a
bit buggy.
No, actually it isn't. See the XML standard at
http://www.xml.com/axml/testaxml.htm: it allows whitespace after the
end of the document, but not before the beginning. And the reason
for this should be clear: since an XML document could use many
different encodings, there would be a catch-22 in trying to discard
whitespace that precedes the XML declaration that indicates what
encoding is being used. See Appendix F of the standard.
..Huh. You're right. I've never encountered it because I don't
usually put whitespace before a document - there's no point, it's just
wasted bytes.
I got bitten by this recently. I wrote a JSP that started like this:
<%@page contentType="application/xhtml+xml"%>
<?xml version="1.0" encoding="UTF-8"?>
<!-- then doctype, and actual content -->
I thought i was being a really good boy and setting my content-type
right. But all that happened is that the client fell over with a parsing
error! Because, of course, after the page directive JSP tag, and before
the XML declaration, there's a newline. So, after JSP processing, my
page actually started "\n<?xml", which is against the rules.
You can fix it easily by deleting the newline, and having the XML decl
follow directly on the heels of the page directive.
In that case, the OP's appropriate course of action would be to tell
whoever's publishing the RSS to fix the feed.
Good luck with that.
tom
whitespace control in JSP.