"Ganesh Muthuvelu" <Ga************ *@discussions.m icrosoft.comwro te in
message news:5F******** *************** ***********@mic rosoft.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:empty pe' 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:complexTyp e>
<xsd:sequence >
<xsd:element name="Name" type="xsd:strin g" />
<xsd:element name="EmployeeT ype" type="xsd:empty pe" />
<xsd:element name="Salary" type="xsd:int" />
</xsd:sequence>
</xsd:complexType >
</xsd:element>
Ganesh,
The following defines <no namespace>:empt ype, 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:simpleTy pe name="emptype">
<xsd:restrictio n base="xsd:strin g">
<xsd:enumeratio n value="fulltime " />
<xsd:enumeratio n value="parttime " />
</xsd:restriction >
</xsd:simpleType>
</xsd:schema>
*************** *******
<xsd:schema xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:tns="urn: GaneshMuthuvelu " targetNamespace =="urn:GaneshMu thuvelu">
....
<xsd:element name="EmployeeT ype" type="tns:empty pe" />
....
<xsd:simpleTy pe 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)