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]
XML uses simple name-value pairs, and XSD is a language fordescribing patterns

Hi Folks,

A simple way to represent data is with name-value pairs, e.g.,

name = John Doe
employer = Acme Inc.
age = 30

People have been using name-value pairs to represent data for at least 60 years.

XML represents data using name-value pairs too!

Consider, what are attributes? Answer: They are just name-value pairs, e.g.,

<Person name="John Doe" employer="Acme Inc." age="30">…</Person>

Wow!

The realization that XML uses simple name-value pairs to represent data was an Aha! moment for me.

Yesterday Michael Kay said something that stirred my mind:

  • A concise notation is great if it makes patterns stand out visually, but not otherwise.
  • But COBOL, and XSLT 1.0, is not concise enough. It's hard to read because it takes too much space so you have to do a lot of scrolling. Again, the patterns don't stand out.

 

When I read that, the word “pattern” really stuck out for me. Then I got to thinking about patterns. What is a pattern? A pattern is something that repeats. For example, look at this string:

               ABCABCABCABC…

We can identify a pattern in that string, namely, ABC is repeated multiple times. Notice the last sentence: I described the pattern using English. Regular expressions (regex) is a language that was explicitly created for describing patterns, i.e., regex is a pattern language. We can describe the pattern using the regex language as follows:

               (ABC)+

So, we have the concept of things that repeat – patterns – and the concept of describing patterns using a language. Regex is one language for describing patterns.

Neat!

Now, consider this series of very simple XML documents:

<label>Mr.</label>

<label>Miss</label>

<label>Mrs.</label>

I detect a pattern and there is a language that I can use to describe the pattern – the XML Schema Language. Here is a description of the pattern, using the XML Schema language:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="label">
        <xs:simpleType>
            <xs:restriction base="xs:string">
               <xs:enumeration value="Mr."/>
                <xs:enumeration value="Miss"/>
                <xs:enumeration value="Mrs."/>
            </xs:restriction>
        </xs:simpleType>
    </xs:element>
</xs:schema>

So, XML Schema is a language for describing patterns.

Wow! I think that is pretty cool.

Thoughts?

/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