Infinetely stupid question

G

GeezerButler

I am really sorry if this sounds stupid. Namespace is just not my cup
of tea.

Could anybody tell me what is wrong with this xsd file (It has
something wrong with the namespaces)

I am getting the error "The element 'Books' is used but not declared in
the DTD/Schema."

If I remove targetNamespace="http://calendar/aiman" and
xmlns:myns="http://calendar/aiman" and change type="myns:BookType" to
type="BookType" it works.

-------------------------------------------------

<?xml version="1.0"?>
<xsd:schema
targetNamespace="http://calendar/aiman"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:myns="http://calendar/aiman"
elementFormDefault="qualified">

<xsd:element name="Books">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Book" type="myns:BookType" minOccurs="1"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:complexType name="BookType">
<xsd:sequence>
<xsd:element name="Name" type="xsd:string" minOccurs="1"/>
<xsd:element name="Author" type="xsd:string" minOccurs="1"/>
<xsd:element name="Award" type="xsd:string" minOccurs="0"/>
<xsd:element name="Price" minOccurs="1">
<xsd:simpleType>
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="0"/>
<xsd:maxInclusive value="5000"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Description" minOccurs="0" maxOccurs="1">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:integer" use="required"/>
</xsd:complexType>
</xsd:schema>
 
G

George Bina

The schema looks valid. Probably you validate an instance document
against this schema. When you have a target namespace set on a schema
then when you declare a global element like Books in your case then
that is a declaration for an element in the schema target namespace. So
in your instance document you need to place that element in the
appropriate namespace. From your description it seems you are placing
it in no namespace so instead of
<Books>

you should have

<Books xmlns="http://calendar/aiman">

Best Regards,
George
 
G

GeezerButler

George said:
The schema looks valid. Probably you validate an instance document
against this schema. When you have a target namespace set on a schema
then when you declare a global element like Books in your case then
that is a declaration for an element in the schema target namespace. So
in your instance document you need to place that element in the
appropriate namespace. From your description it seems you are placing
it in no namespace so instead of
<Books>

you should have

<Books xmlns="http://calendar/aiman">

Best Regards,
George


Thanks!!!! that worked.
 

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

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top