[
Lists Home |
Date Index |
Thread Index
]
- From: Chris Lovett <clovett@microsoft.com>
- To: 'Ken Rawlings' <krawling@vervet.com>, xml-dev@ic.ac.uk
- Date: Thu, 6 Nov 1997 21:10:20 -0800
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
immediately
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
the
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
context.
Good luck, let us know how it goes !
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)
|