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 Lucian Holland <le...@decisionsoft.com> on 2004/07/21 11:00:54 UTC
Warnings for falling back to lax validation?
Hi,
If I validate this:
<test:Root xmlns:test="http://www.example.com">
<test:Wrong/>
</test:Root>
against this schema:
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.com">
<element name="Root">
<complexType>
<sequence>
<any namespace="##any" processContents="lax"/>
</sequence>
</complexType>
</element>
</schema>
Xerces doesn't *report* any problems. This is, of course, legitimate,
because xerces is falling back on validation against the urType as allowed
by the schema spec for lax validation. Examination of the PSVI reveals
that "Root" has only been partially validated, and that "Wrong" has
validity "notKnown".
In the real world outside of schema spec logical formality, however,
there's clearly a problem here: we've got the schema for the "Wrong"'s
namespace, and we know that there is no "Wrong" element (at least as the
contents of that namespace are defined for the purposes of the current
validation episode). As a client of Xerces, the only way I can see to
report this is an error to the user is to examine all of the PSVI after
parsing until I find the node that caused the problem; recreating a useful
error message then becomes a real headache as well :( Is there any chance
that Xerces could report a warning when it can't find an element
declaration but does have a grammar for the relevant namespace? I am at a
loss to think of any real world use case where this behaviour would
actually be harmful, and in many cases I think it would be quite useful...
Lucian
--
Lucian Holland, Technical Architect +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: Warnings for falling back to lax validation?
Posted by Lucian Holland <le...@decisionsoft.com>.
On Fri, 23 Jul 2004, Sandy Gao wrote:
> If you want an error, why did you put "lax" there?
*I* didn't - that's the problem :)
> <choice>
> <any namespace="##targetNamespace" processContents="strict"/>
> <any namespace="##local" processContents="lax/skip"/>
> <any namespace="##other" processContents="lax/skip"/>
> </choice>
Thanks - that's a neat idea which I shall keep in mind. Unfortunately in
this case I can't (directly) change the schema in question. In reality a
schema that forms the basis of a standard with an extensible content model
has to use "lax" to be workable; but inevitably some users of the schema
will have a requirement to ensure that a particular extension that they
employ is correct according to their own schema, which is made a lot
harder if the top level element can have a typo and still "validate"!
This seems to me to be one of the primary use cases for lax validation,
thus my original query about the warning; but I realise I'm out on a limb
as far as the spec. is concerned here :(
Lucian
--
Lucian Holland, Technical Architect +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: Warnings for falling back to lax validation?
Posted by Sandy Gao <sa...@ca.ibm.com>.
If you want an error, why did you put "lax" there? If you use strict, which
seems to be what you want from your description, then you will get an
error.
Or if what you really want is if the instance has an element that's from
your schema's namespace, then there has to be an element declaration, and
skip/lax if it's from some other namespace. Then you can change:
> <sequence>
> <any namespace="##any" processContents="lax"/>
> </sequence>
to
<choice>
<any namespace="##targetNamespace" processContents="strict"/>
<any namespace="##local" processContents="lax/skip"/>
<any namespace="##other" processContents="lax/skip"/>
</sequence>
Cheers,
Sandy Gao
Software Developer, IBM Canada
(1-905) 413-3255
sandygao@ca.ibm.com
Lucian Holland <le...@decisionsoft.com> wrote on 07/21/2004 05:00:54 AM:
> Hi,
>
> If I validate this:
>
> <test:Root xmlns:test="http://www.example.com">
> <test:Wrong/>
> </test:Root>
>
> against this schema:
>
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.example.com">
> <element name="Root">
> <complexType>
> <sequence>
> <any namespace="##any" processContents="lax"/>
> </sequence>
> </complexType>
> </element>
> </schema>
>
> Xerces doesn't *report* any problems. This is, of course, legitimate,
> because xerces is falling back on validation against the urType as
allowed
> by the schema spec for lax validation. Examination of the PSVI reveals
> that "Root" has only been partially validated, and that "Wrong" has
> validity "notKnown".
>
> In the real world outside of schema spec logical formality, however,
> there's clearly a problem here: we've got the schema for the "Wrong"'s
> namespace, and we know that there is no "Wrong" element (at least as the
> contents of that namespace are defined for the purposes of the current
> validation episode). As a client of Xerces, the only way I can see to
> report this is an error to the user is to examine all of the PSVI after
> parsing until I find the node that caused the problem; recreating a
useful
> error message then becomes a real headache as well :( Is there any chance
> that Xerces could report a warning when it can't find an element
> declaration but does have a grammar for the relevant namespace? I am at a
> loss to think of any real world use case where this behaviour would
> actually be harmful, and in many cases I think it would be quite
useful...
>
> Lucian
>
> --
> Lucian Holland, Technical Architect +44-1865-203192
> DecisionSoft Limited http://www.decisionsoft.com
> XML Development and Services
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org