Schema validation

A

askar.bektassov

Hello guys, I'm new to XML so sorry for probably 'obvious' question

I have the following xml schema

<!-- dynamicMeasurement.xsd -->

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:measure="http://www.example.org"
targetNamespace="http://www.example.org">

<xs:complexType name="dynamicObjectsContainer">
...
</xs:complexType>
...
</xs:schema>

<!-- dynamicObject.xml -->

<?xml version="1.0" encoding="UTF-8"?>
<measure:dynamicObjectsContainer
xmlns:measure="http://www.example.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org dynamicMeasurement.xsd">

...
</measure:dynamicObjectsContainer>

But whenever I try to validate the xml file (I'm using oxygen plugin
for eclipse 3.1) I got

cvs-elt.1: Cannot find the declaration of element
'measure:dynamicObjectContainer'
@see: http://www.w3.org/TR/xmlschema-1/#cvs-elt

So the problem is: do I miss some kind of declaration, or namespace?
incredibly I believe I copied another xml, xsd definitions (stored in
another directory) which works without any problem.

Thanks in advance,
cheers
 
G

George Bina

Hi,

You defined in the schema file a complex type with the name
dynamicObjectsContainer. The error says that there is no declaration
for the element with the local name dynamicObjectsContainer that you
use in your instance document. XML Schema does not automatically map an
element name to a type with the same name as the element. You need to
add to your schema an element declaration like below:

<xs:element name="dynamicObjectsContainer"
type="measure:dynamicObjectsContainer"/>

Best Regards,
George
 
A

askar.bektassov

George said:

Thank you very much for reply,

Indeed, looking with little bit more attention on some other xml
examples I can see how the elements declared in the schema and
referenced externally by xml files are usually constructed by

<xs:element name="A">
<xs:complexType>
</xs:complexType>
</xs:element>

but then another question arises naturally - the construction of type:
<xs:element name="dynamicObjectsContainer"
type="measure:dynamicObjectsContainer"/>

shouldn't get inside a infinite recursive loop, since it is declared of
the same type as it is itself?
 
G

George Bina

but then another question arises naturally - the construction of type:
shouldn't get inside a infinite recursive loop, since it is declared of
the same type as it is itself?

No, you have an element with the same name as a type, but they are
different components.

Best Regards,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,888
Messages
2,569,964
Members
46,294
Latest member
HollieYork

Latest Threads

Top