- From: Whitwell, Martyn <martyn.whitwell@ic.ac.uk>
- Date: Mon, 11 Jun 2001 10:35:34 +0100
- To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi there, I'm trying to build an xml schema to describe pages on Imperial College's website (www.ic.ac.uk). I've been using XML Spy to help automate the process of building the schema. My problem lies when I try to define a complex type to encompass several different elements which may or may not be present, e.g. <paragraph> Here is some <bold>bold</bold> text, whereas this text is in <bold><italic>bold italics</italic></bold>. This text does not have any underlined bits, but it could have. </paragraph> After much work, I found this sort of xml document could be described by the schema: <xsd:complexType name="typeEmpText" mixed="true"> <xsd:complexContent> <xsd:extension base="xsd:string"> <xsd:sequence> <xsd:element ref="bold" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="italic" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="underline" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> <xsd:element name="paragraph" type="typeEmpText"/> <xsd:element name="bold" type="typeEmpText"/> <xsd:element name="italic" type="typeEmpText"/> <xsd:element name="underline" type="typeEmpText"/> This schema successfully validated the xml document I had prepared. However, I soon found that XML Spy recoded the complexType typeEmpText "more efficiently", producing: <xsd:complexType name="typeEmpText" mixed="true"> <xsd:simpleContent> <xsd:extension base="xsd:string"/> </xsd:simpleContent> </xsd:complexType> But, this new coding no longer validates my xml document! I guess there must be something wrong with the complexType I defined (indeed, this is most likely as I've not written schemas or DTDs before) - but I can't see the problem? The complexType is deliberately slightly recursive to allow for any amount of sub-elements and sub-sub-elements - is this strictly allowed? Or is Xml Spy in error for believing that my complexType is wrong? All help would be very much welcomed. Thanks, Martyn Whitwell. martyn.whitwell@ic.ac.uk Centre for Computing Services, Imperial College, London, UK.
Received on Monday, 11 June 2001 05:35:42 UTC