[Home] [By Thread] [By Date] [Recent Entries]

  • From: Roger L Costello <costello@m...>
  • To: "xml-dev@l..." <xml-dev@l...>
  • Date: Wed, 3 Jul 2024 20:43:11 +0000

Hi Folks,

As I mentioned previously, I need to convert <Airport_Name> to <name>. Here is an example conversion:

<Airport_Name>JOHN F KENNEDY INTL           </Airport_Name>

<name>JOHN F KENNEDY INTL</name>

The value of <name> is identical to the value of <Airport_Name>, except trailing spaces are removed.

The value of <Airport_Name> is a fixed-length field (30 characters). There is an XML Schema for the <Airport_Name> element, here it is:

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

The value of <name> is a string up to 50 characters, with trailing spaces removed. There is an XML Schema for the <name> element, here it is:

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

I have a file containing an <Airport_Name> for every airport in the world. The airport names are expressed using ASCII characters.

Suppose I iterate over every <Airport_Name> element in the file, convert its value to the appropriate <name> value, and evaluate the following predicate:

normalize-space(Airport_Name) eq name

Suppose the predicate evaluates to true for every conversion.

Have I verified the correctness of my conversion?

If yes, then the way to verify the correctness of an XML-to-XML conversion is:

  1. Validate the source element against the XML Schema for the source element
  2. Validate the converted target element against the XML Schema for the target element
  3. Create a predicate that the source-target conversion must satisfy and evaluate the predicate
  4. If all predicates return true, then the correctness of the conversion is verified


Do you agree?

/Roger



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


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member