Incremental Parsers

Chris Lovett clovett at
Fri Nov 7 05:10:31 GMT 1997

	   Is there any work being done on XML parsers(preferably in
Java) that
	   will allow incremental parsing with validation? I'd like to
have the
	   ability to add elements to a loaded document tree knowing
	   whether that addition is valid. It appears that the Microsoft
	   parser might be able to accomplish this, but not via the
public API.

	   I'd implement this myself, but i'm a little hesitant about
	   vagaries of on the fly DTD validation. Are there any
resources out
	   there that discuss this sort of thing?

	I would call this a "validating XML Object Model", not an
incremental parser, but anyway, it would be relatively simple to modify
the MSXML Object Model to do this since the Document class holds onto
the DTD object and therefore all the state information you need for
validation.  First you would have to find the Element Declaration for
the parent you are adding children to, using
Document.getDTD().findElementDecl(e.getParent().getTagName()), then you
need to create a Context object so you can call checkContent to validate
the addition.  The Context is initialized using initContent() then you
would have to walk through all the children (including the new child)
calling checkContent to make sure the entire content of the parent is
still valid.  It has to be done this way because checkContent is
optimized for validating while you parse.  Similar things would be done
for removeChild.  The attribute validation is a little harder to split
out since currently this is done in AttDef.parseAttValue.  You'd have to
split this into parseAttValue and validateAttValue so you can call the
validation without having to parse anything.  Once you've done that
validation for attributes is easier because it doesn't require any

	Good luck, let us know how it goes !

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