![]() |
|
|
|
#1 |
|
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 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> ------------------------------------------------------------------ If u help me solve this , i'll bless u with my infinte stupidity/wisdom GeezerButler |
|
|
|
|
#2 |
|
Posts: n/a
|
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 --------------------------------------------------------------------- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com |
|
|
|
#3 |
|
Posts: n/a
|
George Bina wrote: > 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 > --------------------------------------------------------------------- > George Cristian Bina > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger > http://www.oxygenxml.com Thanks!!!! that worked. |
|