Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xml-dev] How to handle "newline" characters in an XML parser.

From: Liam Quin <liam@--.--->
To: Redefined Horizons <redefined.horizons@-----.--->
Date: 12/5/2006 7:41:00 PM
On Tue, Dec 05, 2006 at 11:24:55AM -0800, Redefined Horizons wrote:
> I'm nearing the completion of an open source XML parser in Java. (It's
> an event-based, pull parser.)

why?  do we need more parsers? :-)

[...]
> I'm having some trouble figuring out how to handle "newline"
> characters in XML text files on different platforms. I typically
> ignore all whitespace in the parser, but I wanted to count newline
> characters to aid in errror reporting.

You can't ignore whitespace, you have to return it to the application,
except when it's explicitly ignorable because a DTD says so, or when
it's e.g. inside a tag matching the S production.

> I've taken a look at the XML specs, but didn't completely understand
> what they had to say about newline characters.

Can you ask a more specific question?  Are you asking when normalization
happens?  By newline do you mean the character at Unicode code point 10?

Remember that the spaces inside the desc element in:
    <desc>his socks were <em>very</em> <pattern>argyle</pattern>.</desc>
are all important, including the one between </em> and <pattern>.

For error reporting, line counting depends on the platform, and
should probably correspond to using a native text editor on that
platform -- as that's what users will have to use when they
get an error.

Liam

-- 
Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin/
http://www.holoweb.net/~liam/ * http://www.fromoldbooks.org/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent