XML Schema

Having trouble installing Oxygen? Got a bug to report? Post it all here.
gaetano
Posts: 1
Joined: Mon Aug 23, 2004 5:59 am

XML Schema

Post by gaetano »

New to XML Schema. I am writing the entire schema with the prefix of xs: but when I tried to insert the following I rcvd an error saying it was not valid with the schema but then I change it to the prefix of xsd: the error went away but the rest of the schema still has the prefix of xs:
ANY IDEAS!!!!!!!!!!

<xs: simpleType>
<xs: enumeration value="small"/>
</xs:simpleType>


Thank You :?: :?:
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi,

Sure you should get errors with the following schema:

Code: Select all


<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType>
<xs:enumeration value="small"/>
</xs:simpleType>
</xs:schema>
The simpleType element defines a global simple type. You need to specify a name for the global symple type as you can see in one of the errors you get:

E s4s-att-must-appear: Attribute 'name' must appear in element 'simpleType'. test.xsd file:/D:/test/test.xsd 3:18

Also you cannot place enumeration directly inside a simple type, you can restrict for instance the string type to contain only the "small" string as value, like below:

Code: Select all


<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="test">
<xs:restriction base="xs:string">
<xs:enumeration value="small"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
I'm not sure what happens when you use xsd as prefix, you should post a full sample so we can have a look. Anyway, I get for instance an error for:

Code: Select all


<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="test">
<xsd:enumeration value="small"/>
</xsd:simpleType>
</xs:schema>
F The prefix "xsd" for element "xsd:simpleType" is not bound. test.xsd file:/D:/test/test.xsd 3:31

Best Regards,
George
Post Reply