Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / July 2006

Tip: Looking for answers? Try searching our database.

A Simple Schema : What is wrong?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ganesh Muthuvelu - 07 Jul 2006 19:16 GMT
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
John Saunders - 07 Jul 2006 21:38 GMT
> Hello,
> I have a simple schema as shown below. When I validate it, I get the error
[quoted text clipped - 14 lines]
>    </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">
[quoted text clipped - 4 lines]
> </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)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.