W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2011

Here's why I use XML Schemas ... Why do you use XML Schemas?

From: Costello, Roger L. <costello@mitre.org>
Date: Mon, 18 Apr 2011 10:00:08 -0400
To: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-ID: <9E51F88D5247B648908850C35A3BBB500538DD741F@IMCMBX3.MITRE.ORG>
Hi Folks,

I use XML Schemas to check that data meets the expectations and constraints of my business. 

For example, my business supports these credit cards: MasterCard, Visa, and American Express. My business expects purchase orders it receives to use one of those credit cards. My business transmits purchase requests using one of those credit cards. To express my business expectation/constraint in a way that is machine-processable, I created an XML Schema which enumerates the supported credit cards:

    <xs:simpleType name="CreditCards">
        <xs:restriction base="xs:string">
            <xs:enumeration value="MasterCard" />
            <xs:enumeration value="Visa" />
            <xs:enumeration value="American Express" />
        </xs:restriction>
    </xs:simpleType>

Using that simpleType, these datum can be identified as not acceptable:

     Diners Club
     Hello World
     delete * from * 

So, I use XML Schemas to ensure (as best I can) that my business applications receive legitimate data and don't receive bad data (and conversely, that my business applications transmit legitimate data and not bad data).

As a corollary, I don't create XML Schemas with unconstrained data types like this:

    <xs:simpleType name="CreditCards">
        <xs:restriction base="xs:string" />
    </xs:simpleType>

That does not specify my business expectation/constraint. The consequence of its use is that it will unnecessarily expose my business applications to potentially undesirable data such as: 

     Diners Club
     Hello World
     delete * from *

Strong data typing helps me to ensure that my business applications receive legitimate data and don't receive bad data (and conversely, that my business applications transmit legitimate data and not bad data).

I create XML Schemas with strong data typing. I use XML Schemas to ensure that inbound and outbound data meets my expectations and business constraints.

Why do you use XML Schemas?

/Roger
Received on Monday, 18 April 2011 14:00:55 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 18 April 2011 14:00:55 GMT