An OO schema language for XML - PowerPoint PPT Presentation

About This Presentation
Title:

An OO schema language for XML

Description:

SOX schemas are written in XML. easier to read and to write ... synopsis This defines the paragraph element /synopsis /explain model sequence ... – PowerPoint PPT presentation

Number of Views:68
Avg rating:3.0/5.0
Slides: 23
Provided by: caen2
Category:
Tags: xml | language | schema

less

Transcript and Presenter's Notes

Title: An OO schema language for XML


1
An OO schema language for XML
SOX
W3C Note 30 July 1999
2
What is SOX ?
  • A schema language for defining
  • the syntactic structure
  • the partial semantics
  • of XML document types
  • Based on an Object-Oriented approach (Java)
  • Developed by Commerce One

3
Why using SOX instead of DTD ?
  • SOX is an efficient alternative to XML DTDs
  • provide the same services plus
  • SOX schemas are written in XML
  • easier to read and to write
  • can be managed using XML management tools
  • an extensive and extensible set of datatypes
  • embedded documentation
  • extensive use of namespaces
  • OO features reusability, polymorphism,
    inheritance

4
What is an XML schema ?
  • A set of definitions providing a structured way
    of
  • organizing data
  • Defines structure rules using
  • element type definitions
  • datatype definitions
  • namespace references
  • .h file ? XML document .cpp file
  • Characterized by an URI

5
Element type definitions
  • Defines the basic structures found in an XML doc
  • Close to classes in Java
  • Tags in XML document instances
  • Created using keyword elementtype

6
Element type definitions
  • Characterized by
  • A name unique identifier in a given schema
  • A comment HTML text
  • A collection of attributes
  • A model
  • defines structure and composition of an
  • element of that type
  • empty, string, element, sequence, choice

7
Element type definitions
ltelementtype nameparagraph"gt ltexplaingt
ltsynopsisgtThis defines the
paragraph elementlt/synopsisgt
lt/explaingt ltmodelgt
ltsequencegt ltelement
typestring"/gt
ltchoice occurs"2,"gt
ltelement typeint"/gt
ltelement typestring"/gt
lt/choicegt
lt/sequencegt lt/modelgt
lt/elementtypegt
8
Empty content model
  • The element contains no data
  • Useful when
  • element is optional but its presence significant
  • all the data is contained in the attributes
  • ltelementtype name"NoContent"gt
  • ltempty/gt
  • lt/elementtypegt
  • ltNoContentgtlt/NoContentgt

9
String content model
  • Element contains only data, no other element
  • Useful for simple structure containing only data
  • String can be of any datatype
  • ltelementtype name"StringContent"gt
  • ltmodelgt
  • ltstring datatype"string"/gt
  • lt/modelgt
  • lt/elementtypegt
  • ltStringContentgtI love XML !lt/StringContentgt

10
Element content model
  • Content restricted to be only of one type of
    element
  • datatype or other element type
  • Occurrence ?, , , (N,M)
  • ltelementtype name"list"gt
  • ltmodelgt
  • ltelement type"item"
    occurs"2,9"/gt
  • lt/modelgt
  • lt/elementtypegt
  • ltlistgtltitem/gtltitem/gtlt/listgt

11
Sequence content model
  • Content expressed as a sequence of elements
  • Element, sequence or choice
  • Useful to ensure that data appear in a given
    order
  • ltelementtype name"Sequence"gt
  • ltmodelgt
  • ltsequencegt
  • ltelement type"boolean" name"Boolean"/gt
  • ltelement type"float" name"Float"/gt
  • ltelement type"date" name"Date"/gt
  • lt/sequencegt
  • lt/modelgt
  • lt/elementtypegt

12
Choice model content
  • lists a number of elements, sequences or choices
  • Only one of the options appears in the instance
  • ltelementtype name"Choice"gt
  • ltmodelgt
  • ltchoicegt
  • ltelement type"string" name"String"/gt
  • ltelement type"int" name"Integer"/gt
  • lt/choicegt
  • lt/modelgt
  • lt/elementtypegt
  • ltChoicegt ltStringgtThis is a string in a
    choicelt/Stringgt lt/Choicegt

13
Attributes
  • Used to describe an element or its content
  • has a is a relation to content
  • ?
  • nested element has a relation
  • attributes of a class in Java

14
Attributes
  • Characterized by
  • A name unique identifier in a given schema
  • A comment HTML text
  • A type intrinsic or user-defined ? element type
  • A presence specification element required,
  • implied, default, fixed

15
Creating new attribute types
  • Either derived from intrinsic type or from
    another
  • user-defined type
  • Created via keyword attdef
  • 3 operators
  • enumeration
  • scalar
  • varchar

16
Creating new attribute types
ltelementtype name"Car"gt ltempty/gt ltattdef
name"Color"gt ltenumeration datatype"NMTOKEN"gt
ltoptiongtRedlt/optiongt ltoptiongtBluelt/optiongt
lt/enumerationgt ltrequired/gt lt/attdefgt ltattdef
name"Registration"gt ltvarchar maxlength"7"
datatype"string"/gt ltimplied/gt lt/attdefgt ltattd
ef name"Mileagegt ltscalar datatype"double"
digits"6" decimals"1 minvalue"0"/gt ltrequired
/gt lt/attdefgt lt/elementtypegt ltCar color"Blue"
registration"MY CAR" mileage"72881.0"/gt
17
Namespaces
  • Each schema exists in a namespace
  • Can use definitions from other namespaces
  • Import the external namespaces in the schema
  • Libraries in Java
  • Indicates original namespace using xmlns
  • append prefix to the name of imported attribute
  • and element types

18
Namespaces
ltnamespace prefix"containers" namespace "urnx-c
ommerceonedocumentContainer.sox1.0"/gt ltelem
ent name"Can" type"AluminumCan
prefix"containers"/gt ltelement type"PaperCup"
prefix"containers"/gt ltotherAluminumCan
xmlnsother "urnx-commerceonedocumentContainer
.sox1.0"gt ltotherPaperCup/gt
19
Inheritance
  • Element type inherits structure from another
    type
  • can add new structures using append
  • can add new attributes
  • Sequence, element and empty models only
  • Can extend types from other namespaces
  • Uses keyword extend

20
Inheritance
ltelementtype name"Ticket"gt ltmodelgt ltsequencegt
ltelement name"Price" typefloat"/gt ltelemen
t name"Time" type"datetime"/gt lt/sequencegt lt/m
odelgt lt/elementtypegt ltnamespace
prefix"tick"namespace"urnx-commerceonedocument
Ticket.sox1.0"/gt ltelementtype
name"MovieTicket"gt ltextends prefix"tick"
type"Ticket"gt ltappendgt ltelement
name"Title" type"string"/gt lt/appendgt ltattdef
name"PrePaid" datatype"boolean"gt ltrequired/gt
lt/attdefgt lt/extendsgt lt/elementtypegt
21
Polymorphism
  • An element type specifies a specific type in its
  • content
  • An subtype of this type is used instead
  • ltelementtype namePackage"gt
  • ltmodelgt
  • ltelement name"BaseTicket" typeTicket
    occ/gt
  • lt/modelgt
  • lt/elementtypegt
  • ltPackagegtltBaseTicket PrePaidfalsegt
  • ltPricegt15lt/Pricegt ltTimegt1123lt/Timegt
    ltTitlegtMatrixlt/Titlegt
  • lt/BaseTicket gtlt/Packagegt

22
How does it work ?
  • All SOX schemas conforms to the same DTD
  • schema.dtd
  • Everything is converted into Java Beans
  • Reusing definitions is easy
  • Enable robust distributed schema management
Write a Comment
User Comments (0)
About PowerShow.com