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

Re: Cannot find the declaration of ...

From: Jeni Tennison <jeni@jenitennison.com>
Date: Mon, 3 Dec 2001 12:24:06 +0000
Message-ID: <191257215215.20011203122406@jenitennison.com>
To: Nathalie Furmento <n.furmento@doc.ic.ac.uk>
CC: xmlschema-dev@w3.org
Hi Nathalie,

> I have a problem when trying to parse a document with the validation
> feature switched on. It's working without problems if the validation
> is turned off, but when i switch it on (i am using
> xerces-2_0_0_beta3), i got the following error:
>
> org.xml.sax.SAXException: cvc-elt.1: Cannot find the declaration of
> element 'person'.

It's probably to do with the XML Schema namespace declarations. The
XML Schema instance namespace should be
http://www.w3.org/2001/XMLSchema-instance (you've got '1999' rather
than '2001') so change the instance document to:

<?xml version="1.0" encoding="UTF-8"?>
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="person.xsd">
  <name>Isabelle</name>
  <age>1234</age>
</person>

And the elements in the XML Schema document need to be in the XML
Schema namespace of http://www.w3.org/2001/XMLSchema. Since the schema
doesn't have a target namespace, I'd declare this with a prefix rather
than use the default namespace, so try:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="person">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="name" type="xs:string"/>
        <xs:element name="age" type="xs:decimal"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Monday, 3 December 2001 07:24:08 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:25 GMT