Page 1 of 1

XML Schema

Posted: Mon Aug 23, 2004 6:25 am
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 :?: :?:

Posted: Tue Aug 24, 2004 12:44 am
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