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

Way back in 2002, I gave a presentation on XML Schema at a quite 
technically focused developer event. The slides are at [1], and on slide 9 
I attempted to give a quite general answer to your question.  The contents 
of that slide are:

=================

WHAT ARE SCHEMAS FOR?

* Contracts: agreeing on formats

* Tool building: know what the data will be
   before the first instance shows up
   - Database integration
   - User interface tools
   - Programming language bindings

* Validation:  make sure we got what we expected

=================

I think that list holds up pretty well nearly 10 years later. Of course, 
nobody's saying that ever schema should be used for all of these purposes, 
but I think all these uses are important.  I hope the bullet-level 
descriptions are self-explanatory, but if not let me know and I'll elaborate.

Noah


On 4/18/2011 10:00 AM, Costello, Roger L. wrote:
> 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 Wednesday, 4 May 2011 01:31:04 UTC