471,074 Members | 1,430 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,074 software developers and data experts.

A Simple Schema : What is wrong?

Hello,
I have a simple schema as shown below. When I validate it, I get the error

"Type 'http://www.w3.org/2001/XMLSchema:emptype' is not declared. An error
occurred at , (6, 12)."

***************
<?xml version="1.0" encoding="utf-16"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Employee">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Name" type="xsd:string" />
<xsd:element name="EmployeeType" type="xsd:emptype" />
<xsd:element name="Salary" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="emptype">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="fulltime" />
<xsd:enumeration value="parttime" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
**********************

Can someone help?.

Thanks,
Ganesh
Jul 7 '06 #1
1 1314
"Ganesh Muthuvelu" <Ga*************@discussions.microsoft.comwrote in
message news:5F**********************************@microsof t.com...
Hello,
I have a simple schema as shown below. When I validate it, I get the error

"Type 'http://www.w3.org/2001/XMLSchema:emptype' is not declared. An error
occurred at , (6, 12)."

***************
<?xml version="1.0" encoding="utf-16"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Employee">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Name" type="xsd:string" />
<xsd:element name="EmployeeType" type="xsd:emptype" />
<xsd:element name="Salary" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Ganesh,

The following defines <no namespace>:emptype, not xsd:emptype (which is
http://www.w3.org/2001/XMLSchema:emptype). The xsd namespace belongs to
someone else (w3c). You do not define things in someone else's namespace!
<xsd:simpleType name="emptype">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="fulltime" />
<xsd:enumeration value="parttime" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
**********************
<xsd:schema xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:GaneshMuthuvelu" targetNamespace=="urn:GaneshMuthuvelu">
....
<xsd:element name="EmployeeType" type="tns:emptype" />
....
<xsd:simpleType name="emptype">
....

Your schema will be defining names in your namespace. When you need to refer
to those names in the schema itself, you can refer to them with the
tns:<name>. Note that the use of "tns" as a prefix is only a convention -
you can use any prefix you like, but it's frequently useful to define a
prefix which matches the targetNamespace.

I hope that helps.

John
(still learning xsd subleties myself)
Jul 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Chris Vinall | last post: by
9 posts views Thread by Steven C. | last post: by
3 posts views Thread by Eric Lilja | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.