using mixed="true" and trying to set a type
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 2
- Joined: Fri Feb 13, 2009 10:26 pm
using mixed="true" and trying to set a type
Post by ryanparrish »
I may be going at this the entirely wrong way, so don't shy away from pointing out glaring mistakes
What I'm trying to get is an element that looks like this
with the following schema...
And that works fine and all except I would like to define a type (xs:decimal) to the <Weight> element so users of my schema cannot put in strings. However it appears to not be valid to set a type when I have mixed="true", so what am I to do?
What I'm trying to get is an element that looks like this
Code: Select all
<Weight unit="lbs">12.5</Weight>
Code: Select all
<element name="Weight">
<complexType mixed="true">
<attribute name="unit" use="required">
<simpleType>
<restriction base="xs:string">
<enumeration value="lbs"/>
<enumeration value="kgs"/>
</restriction>
</simpleType>
</attribute>
</complexType>
</element>
Re: using mixed="true" and trying to set a type
You need mixed to specify that you have elements and text. In that case you cannot put any other restriction on the text. However, in your case you do not have elements so you can just extend a complex type with simple content from decimal and add the attribute you need:
Best Regards,
George
Code: Select all
<xs:element name="Weight">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute name="unit" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="lbs"/>
<xs:enumeration value="kgs"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
George
George Cristian Bina
-
- Posts: 2
- Joined: Fri Feb 13, 2009 10:26 pm
Re: using mixed="true" and trying to set a type
Post by ryanparrish »
Thank you so much, that is exactly what I have been looking for for days now
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