- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Fri, 25 Jan 2002 18:42:56 +0000
- To: wu.liu@verizon.com
- CC: xmlschema-dev@w3.org
Hi Wu, > The corresponding datatype for MyStructType in schema is: > ===================================================================== > <complexType name="MyStructType"> > <sequence> > <element name="first" type=string"/> > <element name="second" type="string"/> > </sequence> > </complexType> > ===================================================================== > > But how to treat typedef? The following definition gives me error: > ===================================================================== > <complexType name="MyTypedefType"> > <restriction base="MyStructType "/> > </complexType> > ===================================================================== The error is probably arising from a namespace conflict. In: <restriction base="MyStructType" /> the value of the base attribute is interpreted as a qualified name - a local name in a particular namespace. Since you don't have a prefix for that qualified name, the schema validator uses the default namespace. However, from the looks of your XML Schema elements, you've declared the XML Schema namespace as being the default namespace, so the schema validator tries to look for a MyStructType type in the namespace http://www.w3.org/2001/XMLSchema. I guess that you're not using a namespace for your schema? If so, if you don't have a target namespace, then you must declare the XML Schema namespace with a prefix, so you have, for example: <xs:complexType name="MyStructType"> <xs:sequence> <xs:element name="first" type=string"/> <xs:element name="second" type="string"/> </xs:sequence> </xs:complexType> <xs:complexType name="MyTypedefType"> <xs:restriction base="MyStructType "/> </xs:complexType> Alternatively, you could add a target namespace to your schema (using the targetNamespace attribute on the schema element) and declare that namespace with a prefix. Then whenever you have a reference (e.g. the base attribute of the restriction element) then you need to use that prefix. So you'd get: <restriction base="my:MyStructType" /> for example. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Friday, 25 January 2002 13:42:58 UTC