You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by ro...@us.ibm.com on 2000/01/21 00:16:28 UTC

Re: DOM Validation



For the C++ side, it would be a little bit kludgey right now, though I know
what needs to be added to the validator interface to allow for it. But its
not there yet. I think the Java folks are a little further along in this
area.

But basically, it would amount to traversing the tree and passing in the
attributes and children to the validator to have it revalidate them. This
will require, for the C++ side, the addition of a couple of helper methods
on the validator interface in order to keep the outside world from having
to get into more gorpy details than they would probably want to.

Basically it would be:

1 - Validate Children. You would gather the names of the element and it
child elements, and whether there are any non-space text node children. You
would pass this to a helper method which would validate whether that
content is legal or not.

2 - Validate Attributes. This is harder, because the attributes are
supposed to be normalized. But, if the DOM does not normalize the attribute
values when attribute are added programmatically, then the values won't be
correct. The validator can normalize them before it validates them, but
then its not validating what is in the DOM. But, outside of that issue, you
would pass the parent element name, and the key/value pairs of the
attributes to the validator which could confirm that they were valid.


But this has not been added yet. I would want to address some of the issues
about how much DOM does up front when building a DOM programmatically. The
problem is that it probably can't do much, or what it does will have to be
optional, since it cannot assume that the client code modifying or building
a DOM programmatically wants it to be valid in the end. So their might have
to be a pre-validation pass in which the DOM normalizes attributes and such
(and issues its own errors if the elements or attributes don't exist in the
validator), and then does the validation calls.

Anyway, there is a lot to be worked out before this can be done in a robust
way that doesn't have more exceptions than rules.

----------------------------------------
Dean Roddey
Software Weenie
IBM Center for Java Technology - Silicon Valley
roddey@us.ibm.com



Steve Ball <St...@zveno.com>@zveno.com on 01/21/2000 07:02:42 AM

Please respond to xerces-dev@xml.apache.org

Sent by:  steve@zveno.com


To:   xerces-dev@xml.apache.org
cc:
Subject:  DOM Validation



The FAQ doesn't answer my question...

Given that I have built a DOM tree, is there a facility
in Xerces-[CJ] (or any s/w for that matter) that will then
validate the document contained in that DOM tree?
That is, without having to re-parse the source document,
walk the tree and perform validation.

TIA,
Steve Ball

--
Steve Ball            |   Swish XML Editor    | Training & Seminars
Zveno Pty Ltd         |   Web Tcl Complete    |      XML XSL
http://www.zveno.com/ |    TclXML TclDOM      | Tcl, Web Development
Steve.Ball@zveno.com  +-----------------------+---------------------
Ph. +61 2 6242 4099   | Mobile (0413) 594 462 | Fax +61 2 6242 4099