"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)