Page 1 of 1

Simple "article" xsd

Posted: Sun Nov 28, 2004 2:15 am
by Guest
Hello -

I am trying to uild a simple xsd for articles. The article has a title, author, creation, publication, and modification dat as well as some other elements. One of the elements is the "publication". The following doesn´t seem to be valid:

<?xml version="1.0" encoding="UTF-8"?>
<?altova_sps C:\Program Files\Altova\XMLSpy2005\Examples\Conditional.sps?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Article">
<xs:complexType>
<xs:sequence>
<xs:element name="ArticleTitle" type="xs:string"/>
<xs:element name="ArticleAuthor" type="xs:string"/>
<xs:element name="ArticlePublication" type="xs:string" default="The Leader"/>
<xs:element name="ArticleEditionNo" type="xs:integer"/>
<xs:element name="ArticleCreationDate" type="xs:date" default="2005-01-01"/>
<xs:element name="ArticleModificationDate" type="xs:date" default="2005-01-01"/>
<xs:element name="ArticlePublicationDate" type="xs:date" default="2005-01-01"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="The Leader"/>
<xs:enumeration value="Levante Golf"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>

Why?

Best regards,

Neil.

Posted: Mon Nov 29, 2004 10:43 am
by george
Hi Neil,

You cannot have both a complex type and a simple type for an element. If you remove the following

Code: Select all


<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="The Leader"/>
<xs:enumeration value="Levante Golf"/>
</xs:restriction>
</xs:simpleType>
then the remaining schema will be valid:

Code: Select all


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Article">
<xs:complexType>
<xs:sequence>
<xs:element name="ArticleTitle" type="xs:string"/>
<xs:element name="ArticleAuthor" type="xs:string"/>
<xs:element name="ArticlePublication" type="xs:string" default="The Leader"/>
<xs:element name="ArticleEditionNo" type="xs:integer"/>
<xs:element name="ArticleCreationDate" type="xs:date" default="2005-01-01"/>
<xs:element name="ArticleModificationDate" type="xs:date" default="2005-01-01"/>
<xs:element name="ArticlePublicationDate" type="xs:date" default="2005-01-01"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Best Regards,
George

Posted: Wed Dec 01, 2004 12:10 am
by dnedrow
Also, just because I can't resist asking...

Why don't you simply use the DocBook Article schema?

-David