PEReferences in comments

Chris Hubick maillist at
Thu Aug 6 23:06:13 BST 1998

On Thu, 6 Aug 1998, John Cowan wrote:

> Oh, I don't know.  It's common for preprocessors to strip comments;
> the traditional C preprocessor did so, and so does the GNU C compiler
> working in preprocessor-only mode.

	No, I wan't to keep them in.  My parser's main selling/giving 
feature is that it gives a detailed breakdown of the file, based on the
grammar productions of the XML spec, right down to the character level.  I
think this will be very usefull in an authoring application, and I wan't
to keep the comments in.

> > My XMLSource object acts as a
> > buffer, and the parser moves forward and back in that buffer (array type
> > syntax) while trying to identify what is next in the file.
> Why backward and forward?   Pass through everything except a
> % or a <!--.  If it's a %, collect the following Name and the ;,
> look it up, pass through the value.  If it's a <!--, skip everything
> till -->.

	The lower lexical level can do as you say, but above that is the
grammar level.  I have a class for each production in the spec, each one
capable of taking an XMLSource object and parsing itself from the given
start index, generating events, and returning it's end index.  Each class 
throws an unmatched exception if whatever was at that point did not match
that grammar production, or a ProductionViolationException if it did
match (was that thing), but was not well formed.  So the parser figures
out what is where by asking an object to parse itself from the current
point, if it was that thing, fine, if not, discard it and try the next
possibility. As a result of this, it moves back and forth through the
XMLSource object as each XMLObject tries to parse itself, either
succeeding or failing.  If it succeeds, the XMLObjects can also build
themselves into a tree of the document.  It's very OO, and designed to
be clean and extensible rather than fast.  I am basically building
something that will make it easy for me to play with and learn XML and
related technologies, and that will also hopefully be of use to someone
out there, even if only as an educational tool.

Chris Hubick
mailto:chris at

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as:
To (un)subscribe, mailto:majordomo at the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list