You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Eric Ye <er...@locus.apache.org> on 2001/01/03 01:25:57 UTC

Re: question regarding DOM revalidation

Hi, Billy,

To validate an element,

- the first thing you need to do is to resolve the element by calling
getElementDeclIndex() on the current grammar objects, in Xerces 1.2.x, this
is done in XMLValidator.validateElementAndAttributes() method.  With Schema,
the tricky part is the enclosing scope of the element needs to be matained
on a stack, which is fScopeStack in XMLValidator, with DTD, the scope passed
in should always be -1.

- once you have the element index, which is a handle to an element
declaration in the grammar element pool, you can ask all kinds of questions,
such as retrieving the content type of this element, if it is of children
and mix type, then retrieve the contentmodel validator, if it is of "simple"
datatype, then retrieve its datatypevalidator, all of which was done in the
"checkContent" method you mentioned.

- then if attribute validation is needed, all you need to do is to fetch the
head of this element's attribute decl linked list by calling
getFirstAttributeDeclIndex on the current element, and then validate the
actually attribute nodes against this list. You probably have to dig into
"validateElementAndAttributes" a bit more for the details.

The difference between the revalidation on DOM and the normal validation of
a stream is that you already have the document tree, what's left is to
iterate through all the children nodes and marshall up the data to be
validated, you don't even need most of the validation stack except maybe the
scope stack I mentioned.

Good luck with this.
_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org

----- Original Message -----
From: "Billy L. Williams, Jr." <bw...@directcommerce.com>
To: <er...@locus.apache.org>
Sent: Tuesday, January 02, 2001 2:48 PM
Subject: question regarding DOM revalidation


> Hi Eric,
>
> Apologies if you are the wrong person to ask on this question about DOM
> validation (feel free to tell me I'm barking up the wrong tree!): like
> many others, I've looked into upgrading the abandoned
> RevalidatingDOMParser in the Apache Xerces project, and it seems that a
> crucial call it would like to make is the private method
> org.apache.xerces.validators.common.XMLValidator.checkContent(...).  I
> believe you've worked on some of those parts, so I'd like to ask your
> opinion as to how I might be able to go about doing something along
> those lines.  Any thoughts?  I know this is a commonly sought-after
> feature, so any pointers to others working on similar efforts or
> forthcoming revalidation efforts in Xerces would also be greatly
> appreciated.
>
> Thanks!
>
> Billy
>


Re: question regarding DOM revalidation

Posted by "Billy L. Williams, Jr." <bw...@directcommerce.com>.
Thanks for the pointers, Eric.  I may take a stab at this at some point in the
near future, so if anybody else is interested, let me know and I'll keep you
abreast of any developments as they happen on my side.

Billy

Eric Ye wrote:

> Hi, Billy,
>
> To validate an element,
>
> - the first thing you need to do is to resolve the element by calling
> getElementDeclIndex() on the current grammar objects, in Xerces 1.2.x, this
> is done in XMLValidator.validateElementAndAttributes() method.  With Schema,
> the tricky part is the enclosing scope of the element needs to be matained
> on a stack, which is fScopeStack in XMLValidator, with DTD, the scope passed
> in should always be -1.
>
> - once you have the element index, which is a handle to an element
> declaration in the grammar element pool, you can ask all kinds of questions,
> such as retrieving the content type of this element, if it is of children
> and mix type, then retrieve the contentmodel validator, if it is of "simple"
> datatype, then retrieve its datatypevalidator, all of which was done in the
> "checkContent" method you mentioned.
>
> - then if attribute validation is needed, all you need to do is to fetch the
> head of this element's attribute decl linked list by calling
> getFirstAttributeDeclIndex on the current element, and then validate the
> actually attribute nodes against this list. You probably have to dig into
> "validateElementAndAttributes" a bit more for the details.
>
> The difference between the revalidation on DOM and the normal validation of
> a stream is that you already have the document tree, what's left is to
> iterate through all the children nodes and marshall up the data to be
> validated, you don't even need most of the validation stack except maybe the
> scope stack I mentioned.
>
> Good luck with this.
> _____
>
> Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
>
> ----- Original Message -----
> From: "Billy L. Williams, Jr." <bw...@directcommerce.com>
> To: <er...@locus.apache.org>
> Sent: Tuesday, January 02, 2001 2:48 PM
> Subject: question regarding DOM revalidation
>
> > Hi Eric,
> >
> > Apologies if you are the wrong person to ask on this question about DOM
> > validation (feel free to tell me I'm barking up the wrong tree!): like
> > many others, I've looked into upgrading the abandoned
> > RevalidatingDOMParser in the Apache Xerces project, and it seems that a
> > crucial call it would like to make is the private method
> > org.apache.xerces.validators.common.XMLValidator.checkContent(...).  I
> > believe you've worked on some of those parts, so I'd like to ask your
> > opinion as to how I might be able to go about doing something along
> > those lines.  Any thoughts?  I know this is a commonly sought-after
> > feature, so any pointers to others working on similar efforts or
> > forthcoming revalidation efforts in Xerces would also be greatly
> > appreciated.
> >
> > Thanks!
> >
> > Billy
> >