XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Best practice for XSD enumeration values?

If you had to do this as an enumeration, I'd use the following:
<xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="airportType">
        <xsd:simpleType>
            <xsd:list>
                <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                        <xsd:enumeration value="civil"/>
                        <xsd:enumeration value="military"/>
                        <xsd:enumeration value="active"/>
                        <xsd:enumeration value="inactive"/>
                        <xsd:enumeration value="permanent"/>
                        <xsd:enumeration value="temporary"/>
                    </xsd:restriction>                  
                </xsd:simpleType>               
            </xsd:list>
        </xsd:simpleType>
    </xsd:element>
</xsd:schema>
Then you would have:
<airportType>active civil permanent</airportType>

You could also set up a structure:

<airportType>
      <scope>civil</scope>
      <status>active</status>
      <persistence>permanent</persistance>
</airportType>

that decomposes the values in different dimensions.

The <xsd:list> in the first case isn't heavily used, but is very powerful when it's needed.




Kurt Cagle
Community/Managing Editor
Data Science Central, A TechTarget Property
kcagle@techtarget.com or kurt.cagle@gmail.com
443-837-8725


On Wed, Feb 16, 2022 at 8:18 PM Mukul Gandhi <mukulg@softwarebytes.org> wrote:
For verbose XSD enumeration values, perhaps enumeration like following would be better,

<xs:enumeration value='AIRPORT_TYPE_1'>
     <xs:annotation>
          <xs:documentation>active civil airport</xs:documentation>
     </xs:annotation>
</xs:enumeration>

On Wed, Feb 16, 2022 at 9:24 PM Roger L Costello <costello@mitre.org> wrote:
Hi Folks,

This simpleType has a list of enumeration values:

<xs:simpleType name="AirportType">
    <xs:restriction base="xs:string">
        <xs:enumeration value="active civil airport" />
        <xs:enumeration value="active military airport" />
        <xs:enumeration value="active joint (civil and military)" />
        <xs:enumeration value="active airport having permanent type surface runways" />
    </xs:restriction>
</xs:simpleType>

What do you think about those enumeration values? Good? Bad?

A colleague told me: Whitespaces in enumeration values are evil." Do you agree? On the one hand, whitespace enables a value to be easily read. On the other hand, when someone is creating an XML document they might accidentally insert two spaces between words, thus yielding invalid data. Whitespaces good or bad?

The same colleague recommended slamming the words together, and uppercase the first letter of following words, e.g., change "active civil airport" to "activeCivilAirport". But what about values with punctuation such as this value "active joint (civil and military)"? Slamming those words together will create a mess. Should punctuation be prohibited in enumeration values?

This is a pretty long enumeration value: "active airports having permanent type surface runways". Are long values bad? Is there a recommended limit to the length of enumeration values?

I am interested in hearing your thoughts on this issue.


--
Regards,
Mukul Gandhi


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS