W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2001

Re: yet another problem with global stuff

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 6 Dec 2001 14:57:02 +0000
Message-ID: <100175256255.20011206145702@jenitennison.com>
To: Guillaume Rousse <rousse@ccr.jussieu.fr>
CC: xmlschema-dev@w3.org
Hi Guillaume,

> Still using xerces-j 1.4.4
> <persons id="pers">
>   <person id="pers2">
>     <firstName>J. W.</firstName>
>     <lastName>Abalos</lastName>
>   </person>
>   <person id="pers3">
>     <firstName>E.</firstName>
>     <lastName>Abonnenc</lastName>
>   </person>
> [guillaume@silbermann xml]$ xml-check data/cipa.xml
> [Error] cipa.xml:21:24: Attribute "id" is required and must be specified for 
> element type "persons".
> [Error] cipa.xml:21:24: Attribute "id" must be declared for element type 
> "persons".
> The error message is quite confusing. The first seems to complains about a 
> not found required attribute, the second about a found unwaited attribute !

The errors aren't very helpful :) But this is just a namespace
problem. In your schema, you have the attribute id declared at the top
level of the schema, and therefore in the 'model' namespace. In your
instance document, you've got an id attribute that isn't qualified
with a prefix, and thus is not in a namespace.

So the first error message is complaining that you haven't got a
model:id attribute on the person element.

And the second error message is complaining that you've got an
undeclared id attribute (in no namespace) on the person element.

To fix it, either add the model namespace declaration to your instance
document and use:

  <person model:id="...">...</person>

Or change your schema so that the attribute is declared locally and
thus unqualified:

<element name="persons" minOccurs="0" maxOccurs="1">
      <element ref="model:person" minOccurs="1" maxOccurs="unbounded"/>
    <attribute name="id" type="model:KeyType" use="required"/>



Jeni Tennison
Received on Thursday, 6 December 2001 09:57:24 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:56 UTC