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] defining correctness for an XML transformation - how?

Hi Folks,

One of the things that I have learned from this discussion is the importance of a good specification. It is difficult to convert one XML element to another XML element if you have a fuzzy understanding of the two elements.

So, I have nailed down the specifications for <Airport_Name> and <name> ….

Initially I thought the specification for <Airport_Name> was simple: a 30-character fixed length string, composed of ASCII characters. Here is the XSD I created for that specification:

<xs:element name="Airport_Name">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:length value="30"/>
        </xs:restriction>
    </xs:simpleType>
</xs:element>

Then you started asking probing questions: Is Airport_Name required? Can there be leading spaces? Are trailing spaces allowed? Are multiple internal spaces allowed? Are duplicates allowed, i.e., can there be multiple airports with the same name? You said that only ASCII characters are permitted, but your XSD doesn’t reflect that. Can <Airport_Name> be blank, i.e., 30 spaces?

The document/specification I have for Airport_Name doesn’t answer any of those questions, so I examined the data file that I have to get some answers. Here’s what I found:

Is <Airport_Name> required? Yes

Can there be leading spaces in an airport name? No

Can there be trailing spaces? Yes

Are multiple internal spaces allowed? Yes

Are duplicates allowed? Yes

What characters are permitted in an airport name? A-Z, forward slash, left paren, right paren, comma, dash, digits, apostrophe, ampersand, quote, space

Can <Airport_Name> be all blanks? No

Based on those answers, I updated my XSD:

<!-- 
    The Airport_Name element is required.
    Duplicate airport names are allowed. For example, the
    Lowell Field Airport in Anchor Point, Alaska has this  
    Airport_Name:
    <Airport_Name>LOWELL FLD                    </Airport_Name>
    The Lowell Field Airport in Americus, Georgia has the same
    Airport_Name:
    <Airport_Name>LOWELL FLD                    </Airport_Name>
    The value of Airport_Name is a 30-character,
    fixed length string.
    The value must not be all space (x20) characters.
    The value must not contain leading spaces.
    The value may contain zero or more trailing spaces.

    Whitespace is not normalized, i.e., it's acceptable for an
    airport name to contain 2 or more consecutive spaces.
    The name of the airport must be in UPPERCASE letters, A-Z.
    The set of characters permitted: A-Z, forward slash, left
    paren, right paren, comma, dash, digits, apostrophe,
    ampersand, quote, space
    Here are airport names that illustrate the set of characters
    that are permitted:
    <Airport_Name>VANCOUVER/BOUNDARY BAY        </Airport_Name>
    <Airport_Name>ROBERT/BOB/CURTIS MEML        </Airport_Name>
    <Airport_Name>SAN JUAN /UGANIK/             </Airport_Name>
    <Airport_Name>COSTELLO ISLAND, INC          </Airport_Name>
    <Airport_Name>COLUMBUS AFB AUX FLD, (GUNSHY)</Airport_Name>
    <Airport_Name>DUKE FLD,(EGLIN AF AUX NR 3)  </Airport_Name>
    <Airport_Name>KANEOHE BAY MCAS (MARION E CAR</Airport_Name>
    <Airport_Name>WRIGHT AAF (FORT STEWART)/MIDC</Airport_Name>
    <Airport_Name>HOMER-BELUGA LAKE             </Airport_Name>
    <Airport_Name>SCHERTZ AERIAL SERVICE - HUDSO</Airport_Name>
    <Airport_Name>18 MEADOWS AERODROME          </Airport_Name>
    <Airport_Name>SOUTH 80 FLD                  </Airport_Name>
    <Airport_Name>B &amp; B BOYS RANCH              </Airport_Name>
-->
<xs:element name="Airport_Name">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:length value="30"/> 
            <xs:pattern value="[A-Z/\(\),\-0-9'&amp;&quot;][A-Z/\(\),\-0-9'&amp;&quot; ]+"/>
        </xs:restriction>
    </xs:simpleType>
</xs:element>

Recall that I need to convert <Airport_Name> to <name>. Initially my specification of <name> was simple: The value of <name> is a string up to 50 characters, with no trailing spaces. Here is my XSD for the <name> element:

<xs:element name="name">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:maxLength value="50"/>
        </xs:restriction>
    </xs:simpleType>
</xs:element>

I asked the same questions for the <name> element:

Is <name> required? No

Can there be leading spaces? No

Can there be trailing spaces? No

Are multiple internal spaces allowed? Yes

Are duplicates allowed: Yes

What characters are permitted in an airport name? Use the same set of characters that <Airport_Name> uses

Can <name> be all blanks? No

The yellow means it is different from <Airport_Name>.

Here’s my updated XSD:

<!-- 
    The name element is optional.
    Duplicate airport names are allowed. For example, the
    Lowell Field Airport in Anchor Point, Alaska has this name:
    <name>LOWELL FLD</name>
    The Lowell Field Airport in Americus, Georgia has the same name:
    <name>LOWELL FLD</name>
    The value of name is a string with at most 50 characters.
    The value must not be all space (x20) characters.
    The value must not contain leading spaces.
    The value must not contain trailing spaces.
    Whitespace is not normalized, i.e., it's acceptable for an
    airport name to contain 2 or more consecutive spaces.
    The name of the airport must be in UPPERCASE letters, A-Z.
    The set of characters permitted: A-Z, forward slash, left
    paren, right paren, comma, dash, digits, apostrophe,
    ampersand, quote, space
    Here are airport names that illustrate the set of characters
    that are permitted:
    <name>VANCOUVER/BOUNDARY BAY</name>
    <name>ROBERT/BOB/CURTIS MEML</name>
    <name>SAN JUAN /UGANIK/</name>
    <name>COSTELLO ISLAND, INC</name>
    <name>COLUMBUS AFB AUX FLD, (GUNSHY)</name>
    <name>DUKE FLD,(EGLIN AF AUX NR 3)</name>
    <name>KANEOHE BAY MCAS (MARION E CAR</name>
    <name>WRIGHT AAF (FORT STEWART)/MIDC</name>
    <name>HOMER-BELUGA LAKE</name>
    <name>SCHERTZ AERIAL SERVICE - HUDSO</name>
    <name>18 MEADOWS AERODROME</name>
    <name>SOUTH 80 FLD</name>
    <name>B &amp; B BOYS RANCH</name>
-->
<xs:element name="name">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:maxLength value="50"/>
            <xs:pattern value="[A-Z/\(\),\-0-9'&amp;&quot;][A-Z/\(\),\-0-9'&amp;&quot; ]*[A-Z/\(\),\-0-9'&amp;&quot;]"/>
        </xs:restriction>
    </xs:simpleType>
</xs:element>

 

Have I missed anything? Are there additional questions that need answering? Are my specifications complete?

/Roger

 



[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