XML Schema 1.1 for Managers

Copyright © [2010]. Roger L. Costello. All Rights Reserved.
XML Schema 1.1
for Managers
Roger L. Costello
http://www.xfront.com
3 December, 2012
1
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Purpose
• The purpose of this tutorial is to give an overview
of the new features of XML Schema 1.1 without
getting into its syntax.
• It is targeted to managers.
• I show how these new technical features can
benefit your business.
2
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Your 1.0 Schemas will still work
An XML document conforming to a 1.0
schema can be validated using a 1.1 validator,
but an XML document conforming to a 1.1
schema might not validate using a 1.0 validator.
XML Schema 1.1
XML Schema 1.1 is a superset
of XML Schema 1.0
XML Schema 1.0
3
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
XML Schema 1.1 Validators
• The schema-aware version of SAXON
(version 9.3 or later) supports the full XML
Schema 1.1 specification:
http://www.saxonica.com/
• Apache XERCES supports XML Schema 1.1:
http://xerces.apache.org/xerces2-j/
• You can create XML Schema 1.1 schemas
today!
4
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Status
• XML Schema 1.1 became a standard on
April 5, 2012 (the W3C calls it a
“recommendation” not a standard, but they are
the same)
5
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Technology Stack
XML Schema 1.1
XML Schema 1.0
XPath
Each technology
assumes you know
the technologies
beneath it.
Namespaces
XML
6
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Review:
Purpose of
XML Schemas
7
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Two uses of XML
XML as a temporary
transport vehicle:
XML as permanent
storage:
– As soon a the XML gets to its
destination the data is extracted
and put into a permanent
storage mechanism (such as a
database).
– Applications operate on the
data in the permanent storage.
– Applications operate
directly on the XML.
app
XML
app
XML
app
app
app
XML
ship the XML
"shred"
app
8
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
XML as a temporary
transport vehicle
app
XML
app
XML
ship the XML
"shred"
app
An XML Schema can be used as a contract
between the sender and the receiver:
"Here's the information we agree to
exchange, and the format of the
information."
9
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
XML as permanent storage
app
app
XML
app
Often occurring in the form of a workflow:
XML
Rob
Sally
Pete
Jill
Anthony
10
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
XML as permanent storage
(cont.)
XML
app1
app2
app3
app4
Each application does a "unit of work."
It is desirable, after each unit of work,
to assess the system. XML Schemas can
be used to check each application's
output.
11
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
I envision systems working like this:
Check the information–validate that no
rules are being broken.
Do some work.
Then validate that no rules have been
broken (as a result of the work), i.e., check
that you’re still on track.
Then do another unit of work.
Then validate again.
Then do another unit of work.
Then validate again.
And so forth.
12
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Rules
• We live in a world of rules:
– Driving: we follow the rules of the road
– Queues: we form lines at banks and in the
checkout lanes at the supermarket
– Taxes: accountants spend lots of time each year
learning the new tax rules
– Laws: our legal system enforces societies' laws
• Rules guide our actions.
• Rules let us know if we are on or off track.
13
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Rules are Important
All enterprise work as it grows toward perfection becomes rule-based
Roger Costello and Bob Wilson
14
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
XML Schema = Rules
• XML Schemas is all about expressing rules:
– rules about what data is allowed
– rules about how the data must be organized
– rules about the relationships between data
15
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Example: My Vacation
<Vacation>
<Trip segment="1" mode="air">
<Transportation>airplane</Transportation>
</Trip>
<Trip segment="2" mode="water">
<Transportation>boat</Transportation>
</Trip>
<Trip segment="3" mode="ground">
<Transportation>car</Transportation>
</Trip>
</Vacation>
16
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Validate
<Vacation>
<Segment id="1" mode="air">
<Transportation>airplane</Transportation>
</Segment>
<Segment id="2" mode="water">
<Transportation>boat</Transportation>
</Segment>
<Segment id="3" mode="ground">
<Transportation>car</Transportation>
</Segment>
</Vacation>
Validate the XML
document against
the XML Schema
XML Schema
Rule 1: A vacation has segments.
Rule 2: Each segment is uniquely identified.
Rule 3: There are three modes of transportation: air, water, ground.
Rule 4: Each segment has a mode of transportation.
Rule 5: Each segment must identify the specific mode used.
17
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Desirable Rules
mode
air
Transportation
airplane,
hot-air balloon
water
boat,
hovercraft
ground
car,
bicycle
Rule: if mode = air then
transportation must be
either airplane or hot-air
balloon.
Similar rules for water
and ground.
18
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
XML Schema 1.0
cannot detect this error
<Segment id="1" mode="air">
<Transportation>boat</Transportation>
</Segment>
These are inconsistent.
Error!
Why can’t the error be detected using XML Schema 1.0?
Answer: Because the rule on the preceding slide cannot be expressed.
19
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
XML Schema 1.1
• Much more powerful than 1.0
• Can express many more rules (The rule on the
preceding slide can be expressed!)
• Let's see the new features that 1.1 provides …
20
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature:
Express Business Policies
and Rules
using Assertions
21
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Example Policy
Level 1 managers may sign off on purchase
requests that do not exceed $10K.
22
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
This doesn't conform to
company policy
<purchase-request>
<item>Widget</item>
<cost>15000</cost>
<signatureAuthority>Level 1</signatureAuthority>
</purchase-request>
23
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Validate
XML
Schema
Level 1 managers may
sign off on purchase
requests that do not
exceed $10K.
<purchase-request>
<item>Widget</item>
<cost>15000</cost>
<signatureAuthority>
Level 1
</signatureAuthority>
</purchase-request>
XML
Schema
Validator
invalid!
24
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
XML Schema 1.0
• With XML Schema 1.0 business policies and
rules could not be expressed.
– The policy rule on the previous slides could not be
expressed.
• Consequence: developers buried policies and
rules in procedural code.
Level 1 managers may
sign off on purchase
requests that do not
exceed $10K.
Java
program
25
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Disadvantage #1 of Buried
Policies and Rules
I don't understand
Java. I can't
change the policy.
Argh!
Java
program
Business
Person
Policy, expressed in
Java code
26
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Disadvantage #1 of Buried
Policies and Rules
Difficult to change policies and rules.
27
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Disadvantage #2 of Buried
Policies and Rules
How much
can I sign
off on?
Java
program
Manager
Policy, expressed in
Java code
28
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Disadvantage #2 of Buried
Policies and Rules
The policies and rules are
expressed in code
instructions and are less
visible – perhaps only the
programmer knows the
rules.
29
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
XML Schema 1.1
• In XML Schema 1.1 policies and rules can be
expressed.
• Policies and rules are declaratively expressed.
• Consequence:
- Policies and rules can be easily changed
- Policies and rules are transparent
30
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Example Business Rule
1 managers
mayasign
off onclassification
purchase
NoLevel
paragraph
may have
security
requests
do not exceed
$10K.
higher
thanthat
the document's
classification.
31
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
top-secret is higher than secret is higher than confidential is higher than unclassified
32
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Example Document
<Document classification="secret">
<Para classification="unclassified">
...
</Para>
<Para classification="secret">
...
</Para>
<Para classification="unclassified">
...
</Para>
<Para classification="secret">
...
</Para>
</Document>
Ensure that no
<Para> element
has a
classification
higher than the
<Document>
element's
classification
33
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
XML Schema 1.0 versus
XML Schema 1.1
• In XML Schema 1.0 you cannot express the
rule on the previous slide.
• In XML Schema 1.1 you can express it.
34
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Grammar checks
XML Schema 1.0
Business rule checks
XML Schema 1.1
35
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
XML Schema 1.0 versus
XML Schema 1.1
• With XML Schema 1.0 you can express
grammar (syntax) constraints, e.g., this markup
should occur in this order, that data should be a
date, and so forth.
• With XML Schema 1.1 you can still express
grammar constraints but you can also express
data relationships (business rules), e.g., the
classification value here must be less than the
classification value there.
36
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature
assertion
37
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Express Policies and Rules
using Assertions
Policies and rules are expressed in XML
Schema 1.1 using assertions, e.g.,
Assertion: Level 1 managers may sign off on
purchase requests that do not exceed $10K.
Assertion: No paragraph may have a security
classification higher than the document's
classification.
38
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Review
• We've examined the first new feature in XML
Schema 1.1, the ability to express policies and
rules using assertions.
• This feature is a big benefit to businesses: now
businesses can declaratively express their
policies and rules in XML Schemas rather than
burying them in procedural code.
39
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature:
Creating Department-Specific
Data using
Conditional Type Alternatives
40
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Example of Conditional Content
Human Resources (HR) Department:
For each employee store this data: name,
Level 1 managers may sign off on purchase
date of hire, employee number, and
requests that do not exceed $10K.
emergency contact telephone number.
Information Technology (IT) Department:
Level
1 managers
sign
offdata:
on purchase
For each
employeemay
store
this
name,
requests
that do not
exceed
$10K.
areas
of expertise,
and
current
project.
41
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Content varies, depending on dept.
<Employee dept="HR">
<Name>John Doe</Name>
<Hire-Date>2000-01-01</Hire-Date>
<Employee-Num>123</Employee-Num>
<Emergency-Contact>617-123-4567</Emergency-Contact>
</Employee>
<Employee dept="IT">
<Name>John Doe</Name>
<Expertise>XML, XML Schema</Expertise>
<Project>upgrade xyz interface</Project>
</Employee>
42
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
If it's HR then the content must
be an HR type. If it's IT then the
content must be an IT type.
<Employee dept="_________">
</Employee>
43
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Conditional Content
The content of Employee is
conditional to the value of dept.
44
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Example #2
<Publication kind="book">
<Title>Origin of Wealth</Title>
<Author>Eric D. Beinhocker</Author>
<Date>2006</Date>
<ISBN>1-57851-777-X</ISBN>
<Publisher>Harvard Business School Press</Publisher>
</Publication>
<Publication kind="magazine">
<Genre>Scientific</Genre>
<Circulation>733,000</Circulation>
<Founded>1845-08-28</Founded>
</Publication>
The content of Publication depends
on the kind of publication.
45
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
If it's magazine then the content must
be a Magazine type. If it's book then the
content must be a Book type.
<Publication kind="_________">
</Publication>
46
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Conditional Content
The content of Publication is
conditional to the value of kind.
47
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature
alternative
48
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Express Conditional Content
using Alternative
Conditional content is expressed in XML
Schema 1.1 using alternatives, e.g.,
Alternative: if kind="magazine" then the
content is a Magazine type.
Alternative: if kind="book" then the content is
a Book type.
49
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Review
• We've examined two new features in XML
Schema 1.1:
– the ability to express policies and rules using
assertions
– the ability to express conditional content using
alternatives
50
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature:
Expressing Business-wide
Attributes using
Schema-wide Attributes
51
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
A nice feature of HTML
These attributes
can be used
with any HTML
element
52
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
HTML has a set of attributes
that can be used throughout the
document. That's nice.
53
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Schema-wide Attributes
• In XML Schema 1.1 you can create a set of
attributes and identify them as schema-wide,
which means that they apply to every element
in the schema document.
54
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
In XML Schema 1.0 if every
element is to have, say, a "title"
attribute then a title attribute
declaration must be repeated on
every element. That's not nice
(and it's error prone).
55
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature
defaultAttributes
56
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Express Schema-wide Attributes
using defaultAttributes
Schema-wide attributes are expressed in XML
Schema 1.1 using defaultAttributes, e.g.,
defaultAttributes: these attributes apply
throughout the schema document: class, id,
title.
57
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Review
• We've examined three new features in XML
Schema 1.1:
– the ability to express policies and rules using
assertions
– the ability to express conditional content using
alternatives
– the ability to define schema-wide attributes
58
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature:
Enable Business Change
using
Open Content
59
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
U.S. Constitution
• Within the U.S. Constitution it describes how
it can be changed.
• Our forefathers recognized that the world
changes, and if the constitution doesn't adapt
then it will ossify and be useless.
• So they built into the Constitution mechanisms
for how it can be changed.
See section 3.1 of the following paper for a fascinating description of how the
U.S. Constitution has mechanisms for changing itself:
http://www.microfinance.com/English/Papers/Meta-rules.pdf
60
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Open Content
• XML Schemas that can't adapt to a changing
world will ossify and be useless.
• Open content is a mechanism for enabling
schemas to change.
61
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Book Seller Example
• You've coordinated with your clients and
agreed to provide them with this information
about each book:
Title, Author, Date, ISBN, Publisher
You create an XML Schema to express this.
62
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Example (cont.)
• Time passes … some clients request this
additional information:
- number of pages
- binding (hardcover or softcover)
And they want this information NOW!
• Your schema working group meets quarterly.
Updates to support this new information are
months away.
63
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Example (cont.)
• By designing your schemas with open content you
will be able to add the requested new information to
XML instance documents without waiting for the
next quarterly schema meeting.
64
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Example (cont.)
Book Schema
with
Open Content
create XML instance
527
add
new
info
Hardcover
<Book>
<Title>The Origin of Wealth</Title>
<Author>Eric D. Beinhocker</Author>
<NumPages>527</NumPages>
<Date>2006</Date>
<ISBN>1-57851-777-X</ISBN>
<Publisher>Harvard Business School Press</Publisher>
<Binding>Hardcover</Binding>
</Book>
deliver to
clients
65
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Example (concluded)
• The new data is delivered to the clients in a
timely fashion.
• At the next quarterly meeting the XML
Schema is updated: the information provided
for each book is title, author, date, ISBN,
publisher and numPages, binding.
66
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature
openContent
67
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Express Schema-wide Attributes
using openContent
Change is enabled in XML Schema 1.1 using
openContent, e.g.,
openContent: permit new (client-requested)
data to be interleaved among the standardized
data.
68
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Review
• We've examined four new features in XML
Schema 1.1:
– the ability to express policies and rules using
assertions
– the ability to express conditional content using
alternatives
– the ability to define schema-wide attributes
– the ability to facilitate change using open content
69
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature:
Enabling Departments to
Customize Corporate Data
using
override and error
70
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Wish I could customize …
• Oftentimes I've used a tool and thought, "Boy,
if only I could open up this tool and make a
few tweaks, then it would be perfect for my
needs."
• Regrettably the tool is not modifiable and so
I'm stuck using something that's not quite what
I need.
• That said, using the tool is a lot better than
creating a custom tool from scratch.
71
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Unchangeable schemas
can be customized!
• XML Schema 1.1 provides two mechanisms
for customizing another schema without
modifying it:
– override
– error
72
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Override
Office Meeting
meeting
- start time
- end time
- room number
Corporate schema, can't be
changed.
reuse
Conference Meeting
override meeting
with this content:
- track id
- speaker
- room capacity
This schema reuses the corporate
schema, but customizes "meeting"
with the data that is particular to
conference meetings.
73
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
How to change an
unchangeable schema
Schema 1
(read-only)
reuse
Schema 2 overrides items in Schema 1
Schema 2
74
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Recall this earlier example
If it's HR then the content must
be an HR type. If it's IT then the
content must be an IT type.
<Employee dept="_________">
</Employee>
Corporate schema specifies this
75
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
HR Department
The HR department wants to reuse the
corporate schema, but prohibit IT content:
Corporate
Schema
If dept="IT" then error
reuse
<Employee dept="_________">
Generate an
error if dept
is accidentally
assigned IT.
HR
Schema
</Employee>
76
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature
override
77
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature
error
78
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Enable Customization using
override and error
Enabling customization is expressed in XML
Schema 1.1 using override and error, e.g.,
override: replace items in the corporate schema
with your own data (and without changing the
corporate schema).
error: disallow the use of certain items in the
corporate schema.
79
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Review
• We've examined five new features in XML
Schema 1.1:
– the ability to express policies and rules using
assertions
– the ability to express conditional content using
alternatives
– the ability to define schema-wide attributes
– the ability to facilitate change using open content
– the ability to customize schemas that ordinarily are
unchangeable, using override and error
80
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature:
Enabling Dissemination of
New Announcements
using
inherited attributes
81
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
<Merchandise discount="10%">
Want this discount
information to be visible
(disseminated) throughout
the document
<Coats>
…
</Coats>
<Shirts>
…
</Shirts
<Pants>
…
</Pants
</Merchandise>
82
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
<Merchandise discount="10%">
i.e., want this discount
attribute to be "inherited"
<Coats>
…
</Coats>
<Shirts>
…
</Shirts>
<Pants>
…
</Pants>
</Merchandise>
83
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
<Contract language="FR">
Want this language
information to be visible
(disseminated) throughout
the document
<Foreign-Release>
…
</Foreign-Release>
<State-Department>
…
</State-Department>
<Legal>
…
</Legal>
</Contract>
84
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
<Contract language="FR">
i.e., want this language
attribute to be "inherited"
<Foreign-Release>
…
</Foreign-Release>
<State-Department>
…
</State-Department>
<Legal>
…
</Legal>
</Contract>
85
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature
inheritable
86
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Enable Information Dissemination
using inheritable attributes
Enabling the dissemination of information is
expressed in XML Schema 1.1 using
inheritable attributes, e.g.,
inheritable: this attribute can be viewed and
used from here on in.
87
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Review
• We've examined six new features in XML
Schema 1.1:
–
–
–
–
–
the ability to express policies and rules using assertions
the ability to express conditional content using alternatives
the ability to define schema-wide attributes
the ability to facilitate change using open content
the ability to customize schemas that ordinarily are
unchangeable, using override and error
– the ability to disseminate information within a document
using inheritable attributes
88
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature:
Enabling User-Friendly
Arrangement of Information
using "all"
89
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Camera Lens
The camera comes with
a 37-155mm zoom lens
that has an f-stop of 4.811.7
The camera comes with
a lens that has an f-stop
of 4.8-11.7 and is a
37-155mm zoom
90
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Does Order Really Matter?
<Camera-Lens>
<f-stop>4.8-11.7</f-stop>
<focal-length>37-155mm zoom</focal-length>
</Camera-Lens>
-- versus --
<Camera-Lens>
<focal-length>37-155mm zoom</focal-length>
<f-stop>4.8-11.7</f-stop>
</Camera-Lens>
91
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Does Order Really Matter?
Probably not. To be user-friendly,
allow both orders.
92
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Any Order
• XML Schema 1.0 was pretty controlling in
terms of the order of data.
• XML Schema 1.1 is much less controlling;
schemas can be designed to allow the data to
be arranged in any order.
93
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
New Feature
all
Note: "all" is found in XML Schema 1.0, but it did
not permit elements with maxOccurs of 2 or more.
XML Schema 1.1 does not have this restriction.
94
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Enable a user-friendly
arrangement of information
using "all"
Enabling information to be expressed in any
order is accomplished in XML Schema 1.1
using the "all" element, e.g.,
all: provide the f-stop and the focal-length of
the camera lens in an order that is useful to
you.
95
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Review
• We've examined seven new features in XML
Schema 1.1:
–
–
–
–
–
the ability to express policies and rules using assertions
the ability to express conditional content using alternatives
the ability to define schema-wide attributes
the ability to facilitate change using open content
the ability to customize schemas that ordinarily are unchangeable,
using override and error
– the ability to disseminate information within a document using
inheritable attributes
– the ability to present the information in a user-friendly order, using the
"all" element
96
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Other New Features
97
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
The many names of "subway"
• There are different ways of saying "I took the
subway into town"
–
–
–
–
In Boston we say "I took the T into town"
In D.C. they say "I took the metro into town"
In London they say "I took the tube into town"
In Chicago they say "I took the L into town"
98
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Substitution
• XML Schema 1.1 enables you to express "T can
be substituted for either metro or tube or L"
metro
L
tube
substitutable for
substitutable for
substitutable for
T
99
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Multiple Identifiers
My SSN is …
My employee # is…
My driver's license # is …
100
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Multiple ID values
• XML Schema 1.1 enables you to associate
multiple ID values to an element.
Stereo
model-number="…"
serial-number="…"
101
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Symbol for the decimal point in
U.S.A. versus France
15.7 (USA)
15,7 (France)
102
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
What's the symbol for the decimal
point in XML Schema 1.1?
15.7
103
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
What's the symbol for the decimal
point in XML Schema 1.1?
15.7
Isn't that unfair to the folks in France?
104
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Vendor-unique Extensions
• XML Schema 1.1 allows vendors to extend the
language.
• Thus a vendor may create a new decimal
datatype (French:decimal) with "," as the
decimal point.
105
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Other new datatypes
• anyAtomicType: the anyAtomicType is the union of
the values of all the primitive types (string + integer +
boolean + …)
• dateTimeStamp: a dateTimeStamp value is a date
plus time plus timezone
• yearMonthDuration: a yearMonthDuration value is
a duration consisting of years and months
• dayTimeDuration: a dayTimeDuration value is a
duration consisting of days and time
106
Copyright © [2010]. Roger L. Costello. All Rights Reserved.
Summary
• XML Schema 1.1 has lots of powerful new
features.
• I hope this tutorial has convinced you that
these new features can benefit your business.
• I recommend switching to XML Schema 1.1 as
soon as possible.
107