Schema Concepts
R. Alexander Milowski
milowski@sims.berkeley.edu
School of Information Management and Systems
#1
What Are Schemas?
Structure Relations?
Constraints?
Typing?
#2
Schema Language vs Schema Language
Modeling everything is impossible.
Constraints are a slippery slope.
Some languages don't really have a type system.
But the XML Schema language from the W3C does handle a lot of requirements.
XML Schema supported concepts will be listed with a check mark:
#3
Structure Relations
What elements are allowed to be document elements?
What children can an element contain?
What attributes can an element have?
What elements have values?
#4
Structure - Children & Models
Element's that contain elements are typically modeled:
sequences of elements (e.g. A followed by B followed by C)
choices of elements (e.g. A, B, or C)
occurrences (e.g. one or more, between 5 and 10, optional)
Models allow combinations of the above. (but there's restrictions)
#5
Structure - Mixed Content
Sometimes elements and text occur at the same level:
<p>This is a paragraph with a link to <a href="...">something</a>.</p>
Its called "mixed content".
#6
Structure - Wildcards
With namespaces, you might want to say:
Anything from a particular namespace goes here.
Anything from a set of namespaces goes here.
Anything except the current namespace.
Anything but a particular namespace goes here.
#7
Structure - Attributes
What attributes are associated with elements.
But you might want to say:
It is optional
It has a certain value
Here's a default value.
#8
Structure - Validation Control
Controling how all the children are validated against their
schema.
Controlling:
Strict validation
"Process if you got 'em"
"I don't care."
#9
Types of Constraints
Constraining values (e.g. the value of this attribute must be a
date).
Cross-field validation.
Referential integrity.
#10
Value Constraints
Simple lists of values.
data types (e.g. integers, dates, etc.)
regular expressions.
#11
Cross Referencing Constraints
Keys & Key-refs like in XSLT.
Simple links within a document.
Links external to a document.
#12
Cross-Field Constraints
Conditional value rules (e.g. if this attribute has value 'x' then this other must have value 'y').
Structural rules (e.g. if this element has this structure, then this other must have another structure.).
Mixing the above.
#13
Typing
Type derivation for data types (simple types).
Type derivation for element structures.
Typing vs. use.
#14
Value Constraints as Typing
Built-in data type hiearchy.
Custom derivations (e.g. integers between 1 and 10).
Value enumeration.
Lexical pattern matching (e.g. regular expressions).
#15
Element Structure Derivation
Extending content models:
Adding to the end?
Adding to the start?
Adding at a specified start?
Adding attributes.
Restricting attributes:
Making optional required.
Excluding optional attributes.
Restricting values.
#16
Name vs. Type
This distinction is :
All elements are types?
Elements have types but types can have names.
Example:
<person><name>Alex</name></person>
Is this an element type named 'person'?
Is this an element named 'person' that is an instance of a type with child structure 'name'.?
#17
Polymorphic Content
Example:
<people> <student status='freshman'><name>Jimmy Dean</name></student> <professor><name>Bob Glushko</name></professor> <lacky><name>Alex Milowski</name></lacky> </people>
Each element 'student', 'professor', and 'lacky' could have a type derived from type 'person'.
The model for 'people' says things of type
'person' goes here.
#18
XML Schema
Developed as the result of a number of XML Schema submissions (SOX, XML Data, etc.)
One main goal was to replicate modeling techniques used in DTDs.
And to provide modern typing and data typing.
All this packaged syntactically as an XML document.
XML Schema became a recommendation in May 2001.