RE: Attributes, simpleContent, etc.

> Oops, I think I missed a bit.  I think you have to do this in two stages:
>
> 1. Create the positive double by restricting double.
>
> 2. Extending the new positive double simpleType into a simpleContent.
>

Thanks, Pete:

After thinking about this I decided that it would also be good to have an AreaType and a
LengthType, etc., which will be helpful shorthand in the remainder of the schema. So, with
your suggestions above, this becomes:

<!-- Global Types for this file -->

<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>

<!-- Wing Area -->

<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>

The above definition worked well, and the documentation was produced correctly in
oXygenXML, which also validated the following XML:

<wingarea unit="FT2"> 174.0 </wingarea>

Thanks for your help. This is fun stuff, but sometimes frustrating.

Jon
Project Coordinator,
JSBSim Flight Dynamics Model Project
www.jsbsim.org

Received on Sunday, 27 November 2005 13:55:59 UTC