You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Williamson, Siehnai" <sw...@docucorp.com> on 2002/02/12 18:09:20 UTC

Schema Validator broken?

Hi,

Why does SchemaElementDecl in SEnumVal example contain elements from the XML
document even if it is not in the schema?  Shouldn't it only contain those
elements or values that are listed in the schema?

I have a dummy xml document with a root element called "dummy" pointing to
the document's schema.  Whenever I run SEnumVal, the last element retrieved
from SchemaElementDecl is this "dummy" element.  Since I don't know if the
user will use the word "dummy" as the root element for her dummy document, I
can't therefore check for "dummy" and eliminate it in my application.  The
only alternative is to figure out the last element validated and then assume
that this is the root element from the xml document.  

Is there a better way to do this in Xerces or is there going to be a fix to
remove the root element from being listed in the validator?

  



Re: Schema Validator broken?

Posted by Alberto Massari <al...@exceloncorp.com>.
At 11.06 12/02/2002 -0800, you wrote:
>If you turn off validation (valScheme==Never), then all elements are just
>marked as declared for ease of processing.  Since if validation is off, the
>parser does not really care if the element is defined in the grammar or 
>not, so
>for performance reason, all elements are just marked as "Declared".
>
>But if you've turned on validation, and still see dummy root that is not
>defined in grammar has createReason==Declared, then it is a bug ............
>and please let us know if that's the case.

Thanks for the explanation; validation was turned off using 
setDoValidation(false).

Alberto


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Schema Validator broken?

Posted by Tinny Ng <tn...@ca.ibm.com>.
If you turn off validation (valScheme==Never), then all elements are just
marked as declared for ease of processing.  Since if validation is off, the
parser does not really care if the element is defined in the grammar or not, so
for performance reason, all elements are just marked as "Declared".

But if you've turned on validation, and still see dummy root that is not
defined in grammar has createReason==Declared, then it is a bug ............
and please let us know if that's the case.

Tinny

Alberto Massari wrote:

> At 10.47 12/02/2002 -0800, you wrote:
> >The ElementDecl pool from the validator is a collection of all the
> >elements appear in the grammar, and in the XML document.
> >
> >Each element has a "CreateReason", if this element has a corresponding
> >definition in the grammar, then the "CreateReason" == Declared.  If this
> >element only appears in the DTD ATTLIST, but itself is not defined in the
> >grammar, then the "CreateReason" == AttList.  If this element only appears
> >in the XML document, but not defined in the grammar, then the
> >"CreateReason" == JustFaultIn ... etc.
> >
> >So you can check the createReason by calling getCreateReason() and bypass
> >those no needed.  Or if you only want those element that are defined in
> >the grammar, you can call isDeclared() directly.
>
> Tinny,
> as far as I remember, last time I parsed a document with a dummy root the
> create reason was Declared, just like the elements found in the XMLSchema.
>
> Alberto
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Schema Validator broken?

Posted by Alberto Massari <al...@exceloncorp.com>.
At 10.47 12/02/2002 -0800, you wrote:
>The ElementDecl pool from the validator is a collection of all the 
>elements appear in the grammar, and in the XML document.
>
>Each element has a "CreateReason", if this element has a corresponding 
>definition in the grammar, then the "CreateReason" == Declared.  If this 
>element only appears in the DTD ATTLIST, but itself is not defined in the 
>grammar, then the "CreateReason" == AttList.  If this element only appears 
>in the XML document, but not defined in the grammar, then the 
>"CreateReason" == JustFaultIn ... etc.
>
>So you can check the createReason by calling getCreateReason() and bypass 
>those no needed.  Or if you only want those element that are defined in 
>the grammar, you can call isDeclared() directly.

Tinny,
as far as I remember, last time I parsed a document with a dummy root the 
create reason was Declared, just like the elements found in the XMLSchema.

Alberto


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Schema Validator broken?

Posted by Tinny Ng <tn...@ca.ibm.com>.
The ElementDecl pool from the validator is a collection of all the
elements appear in the grammar, and in the XML document.

Each element has a "CreateReason", if this element has a corresponding
definition in the grammar, then the "CreateReason" == Declared.  If this
element only appears in the DTD ATTLIST, but itself is not defined in
the grammar, then the "CreateReason" == AttList.  If this element only
appears in the XML document, but not defined in the grammar, then the
"CreateReason" == JustFaultIn ... etc.

So you can check the createReason by calling getCreateReason() and
bypass those no needed.  Or if you only want those element that are
defined in the grammar, you can call isDeclared() directly.

Tinny

"Williamson, Siehnai" wrote:

>
>
> Hi,
>
> Why does SchemaElementDecl in SEnumVal example contain elements from
> the XML document even if it is not in the schema?  Shouldn't it only
> contain those elements or values that are listed in the schema?
>
> I have a dummy xml document with a root element called "dummy"
> pointing to the document's schema.  Whenever I run SEnumVal, the last
> element retrieved from SchemaElementDecl is this "dummy" element.
> Since I don't know if the user will use the word "dummy" as the root
> element for her dummy document, I can't therefore check for "dummy"
> and eliminate it in my application.  The only alternative is to figure
> out the last element validated and then assume that this is the root
> element from the xml document.
>
> Is there a better way to do this in Xerces or is there going to be a
> fix to remove the root element from being listed in the validator?
>
>
>