[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Rebelling parser writers (Was: ]]> within a CDATA marked section ?)

  • From: James Clark <jjc@j...>
  • To: xml-dev@i...
  • Date: Fri, 28 Nov 1997 09:28:01 -0500

registered trademark character in xml
Richard Light wrote:
> 
> In message <01BCFB68.64DAE950@x...>, Jarle Stabell
> <jarle.stabell@d...> writes
> 
> >After attempting to process a document containing errors, I want to present to
> >the user a list of error messages, and when the user clicks on one of these
> >messages, I want to highlight the exact part of the document where the error
> >occurs.
> >The problem with entity expansion is that the parser isn't parsing what the
> user
> >literally wrote into the entity definitions, it is parsing a
> processed/"virtual"
> >version, which *may* not be a real subpart of the document, so one has to map
> >"virtual" locations/positions to physical (real document) positions, which
> >doesn't seem trivial to me. It is also likely to give slightly confusing error
> >messages, as it may be mentioning expanded stuff ("<xxx>") which the user never
> >wrote, the user may have written "&lt;xxx&gt;" etc.
> 
> I don't think this is as much of a problem as you fear.  Every entity is
> physically declared somewhere in a real source - usually a good ol' file
> on disc.  Of course, that file may not be the one you started from ...
> 
> My RunSP program (http://www.light.demon.co.uk/runsp) does exactly what
> you describe (for nsgmls).  It runs it under Windows and then allows the
> user to navigate from one error message to the next, in a simple editor
> environment that lets them sort out the problems they find.  All I did
> was to parse the error messages, pick out file name, line number and
> character offset, and place a bookmark at the relevant point in the file
> concerned.  This works equally well for errors in the DTD or SGML
> Declaration as for those in what we think of as the 'real document'.
> (Which is something that never occurred to me when designing RunSP - but
> of course the Declaration and DTD are equally part of the document as
> far as the parser is concerned.)

SP does exactly the sort of virtual location to physical location
mapping that Jarle was talking about.  For example, given a file
test.xml:

<!DOCTYPE doc [
<!ELEMENT doc (#PCDATA)>
<!ENTITY % e1 "!ELEMENT">
<!ENTITY e2 "&#60;%e1;">
]>
<doc>&e2;</doc>

nsgmlsu -e will report:

In entity e2 included from test.xml:6:9
nsgmlsu:test.xml:3:16:E: "ELEMENT" declaration not allowed in instance

The position it reports (column 16 in line 3 of test.xml) is the
position of "ELEMENT" in test.xml.  It has kept track of the fact that
the 3rd character in the replacement text of e2 came from the 2nd
character in the replacement text of e1 and that the 1st character in
the replacement text of e1 was specified at line 3 column 16 of
test.xml.  Implementing this is not trivial.

James



xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.