Simple "article" xsd
This should cover W3C XML Schema, Relax NG and DTD related problems.
Simple "article" xsd
Post 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.
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.
Hi Neil,
You cannot have both a complex type and a simple type for an element. If you remove the following
then the remaining schema will be valid:
Best Regards,
George
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>
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>
George
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service