Title: Modelling
1Modelling
- Hachim Haddouti
- Al Akhawayn University
- SSE
- H.Haddouti_at_alakhawayn.ma
- http//mail.alakhawayn.ma/H.Haddouti
2TOC
- Intro
- DTD, XML Schmea
- Derivation of Schemainformationen from XML
Documents - Metrics
- Recommendations
3Schema for XML Documents
- DTDs
- ( SGML, simple, compact, easily readable, no XML
Syntax) - XML Schema
- (more presentation possibilties, Data types,
exact cardinalities, ...)
4Document Type Definitions
- See slides of first chapter
5XML Schema /2
- In May 2001, XML Schema officially
- More presentation possibilities,
- Simpler schema language
- More built-in datatypes
- Ability to define own datatypes
- Ability to restrict datatype values,
- Syntax closer to that of XML
- more complexity than DTD
6Built-in Types
www.w3.org/TR/2001/REC-xmlschema-2-20010502
7Extensibility of XML schemas
- Namespace a collection of type definitions and
element declarations. - Can be shared between different schema to aid in
the reuse of types and constructs. - Expand more on you own (Namespace Qualification,
target namespaces, importing/inlcuding/redefining
namespaces
8Definition von Integrity Check
- Integrity Conditions to be met in XML Documents
- uniqueness
- key
- Referential integrity (keyref). Â
- Definition of Elements and Attributes using Xpath
expression.
9Referential integrity
- Recall ID, IDREF
- can these serve as primary/foreign keys?
10Referential integrity
- Uniqueness
- XML Schema enables us to indicate that any
attribute or element value must be unique within
a certain scope - Fields defined as unique cannot contain null
values - Still not a candidate for primary/foreign key
11Relationship constraints, cont.
- KEY, KEYREF
- like unique, key must be unique within a certain
scope - key can be based on multiple fields
- key can be referenced
- analogous to primary/foreign key
- Compare ID in DTD to key in XML Schema? Global
Uniqueness?
12Example
- ltxskey name"Hotel_key"gt
- ltxsselector xpath"/Hotelinformationen/Hotel"
/gt - ltxsfield xpath"_at_HotelID/"/
- lt/xskeygt
- Â
- ltxskeyref name"Hotel_directory_keyref"
refer"Hotel_keygt - ltxsselector xpath"/ Hotel_directory
/Location/Hotels"/gt - ltxsfield xpath"_at_HotelID"/gt
- lt/xskeyrefgt
- selector indicate a node set, that has to be
unique. - With field you specify exactly, which element
value or Attribut should be unique.
13Key, Keyref Defining a combined key
ltxselement name"vehicle"gt ltxscomplexTypegtlt!--
begin anonymous type--gt . . . ltxsattribute
name"plateNumber" type"xsinteger"/gt
ltxsattribute name"state" type"twoLetterCode"/gt
lt/xscomplexTypegt lt/xselementgt
14Key, Keyref Defining a combined key
ltxselement name"person"gtlt!--new global
element--gt ltxscomplexTypegt ltxssequencegt .
. . ltxselement name"car"gtlt!-- begin local
element--gt ltxscomplexTypegt
ltxsattribute name"regState" type"twoLetterCode"
/gt ltxsattribute name"regPlate"
type"xsinteger"/gt lt/xscomplexTypegt
lt/xselementgt lt/xssequencegt
lt/xscomplexTypegt lt/xselementgt
15Key, Keyref Defining a combined key
ltxskey name"regKey"gt lt!-- vehicles are keyed
by a pair of state and plate --gt ltxsselector
xpath".//vehicle"/gt lt!--node group -gt scope --gt
ltxsfield xpath"_at_state"/gt ltxsfield
xpath"_at_plateNumber"/gt lt!-- combination must
be unique--gt lt/xskeygt ltxskeyref
name"carRef" refer"regKey"gt ltxsselector
xpath".//car"/gt ltxsfield xpath"_at_regState"/gtlt!
-- order and type important --gt ltxsfield
xpath"_at_regPlate"/gt lt/xskeyrefgt
16Tradeoffs
- DTDs
- Large Amount of Tool Support
- Established
- Non-XML Syntax
- No typing of values
- Difficult to specify unordered sets of
subelements - For high speed validation, DTDs may outperform
Schema - XML Schema
- More control over scope of elements and where
they can be used - XML syntax
- Datatypes
- Namespaces
- Able to specify sets more precisely
- Less Tool Support
- More complicated language
17XML Schema vs. DTD
- XML Schema contains all modelling abilities of
DTD, except Entities. - Conversion DTD in XML Schema lossless, Entities
will be expanded. - Conversion XML Schema in DTDs with loss
18Usage of XML Schema
- Data centric Applications
- Import in and Export from DBs
- Use data types and integrity checks
- XML Databases SQL/XML
19Tools
- Editors
- XMLSpy (www.xmlspy.com)
- XML Authority (www.extensibility.com/xml_resources
/modeling.htm) - XML Writer
- XML-Prozessors
- XML Schema Quality Checker of IBM alphaworks
(www.alphaworks.ibm.com/tech/xmlsqc) - XML Schema Validator of Oracle (technet.oracle.com
/tech/xml/)