"complex type definition representation error"
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 20
- Joined: Sat Nov 26, 2005 5:17 pm
- Location: Houston, Texas, USA
- Contact:
"complex type definition representation error"
I am just beginning to work with schemas. I'm having a little trouble authoring a schema. (I'm using the oXygenXML editor, if that matters). If there is a better place for me to post this, please let me know.
I have an element in my XML document that looks as follows:
<wingarea unit="FT2"> 174.0 </wingarea>
The element is required, the content must be greater than 0, and the unit can be one of FT2 or M2 (the unit is optional, with FT2 being the default). I've read up on this, but so far I've been unsuccessful at making the correct schema, according to the oXygen XML error messages I get.
Here's what I've got so far:
<xs:element name="wingarea">
<xs:complexType>
<xs:simpleContent>
<xs:restriction base="xs:double">
<xs:minExclusive value="0"/>
<xs:attribute name="unit" use="optional" default="FT2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="M2"/>
<xs:enumeration value="FT2"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:element>
I get an error message when I try and validate a document using this schema:
--- start error message ---
"Complex Type Definition Representation Error for type '#AnonType_wingarea'. When <simpleContent> is used, the base type must be a complexType whose content type is simple, or, only if restriction is specified, a complex type with mixed content and emptiable particle, or, only if extension is specified, a simple type. 'double' satisfies none of these conditions. URL: http://www.w3.org/TR/xmlschema-1/#src-ct"
--- end error message ---
I'd be grateful if someone can give me a "simpleType" of explanation of where I've gone wrong! Thanks.
Jon Berndt
League City, TX
I have an element in my XML document that looks as follows:
<wingarea unit="FT2"> 174.0 </wingarea>
The element is required, the content must be greater than 0, and the unit can be one of FT2 or M2 (the unit is optional, with FT2 being the default). I've read up on this, but so far I've been unsuccessful at making the correct schema, according to the oXygen XML error messages I get.
Here's what I've got so far:
<xs:element name="wingarea">
<xs:complexType>
<xs:simpleContent>
<xs:restriction base="xs:double">
<xs:minExclusive value="0"/>
<xs:attribute name="unit" use="optional" default="FT2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="M2"/>
<xs:enumeration value="FT2"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:element>
I get an error message when I try and validate a document using this schema:
--- start error message ---
"Complex Type Definition Representation Error for type '#AnonType_wingarea'. When <simpleContent> is used, the base type must be a complexType whose content type is simple, or, only if restriction is specified, a complex type with mixed content and emptiable particle, or, only if extension is specified, a simple type. 'double' satisfies none of these conditions. URL: http://www.w3.org/TR/xmlschema-1/#src-ct"
--- end error message ---
I'd be grateful if someone can give me a "simpleType" of explanation of where I've gone wrong! Thanks.
Jon Berndt
League City, TX
-
- Posts: 20
- Joined: Sat Nov 26, 2005 5:17 pm
- Location: Houston, Texas, USA
- Contact:
Fixed
I've fixed this myself.
I hope this is correct, and helpful to someone else.
Jon
Code: Select all
<xs:simpleType name="AreaType">
<xs:restriction base="xs:string">
<xs:enumeration value="M2"/>
<xs:enumeration value="FT2"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="PositiveNumber">
<xs:restriction base="xs:double">
<xs:minExclusive value="0"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="wingarea">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="PositiveNumber">
<xs:attribute name="unit" use="optional" default="FT2" type="AreaType"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
Jon
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
Yes it does what you requested and is a valid XML Schema construction.
Regards,
Sorin
Yes it does what you requested and is a valid XML Schema construction.
Regards,
Sorin
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