XML Data Reduced Schema
description
Transcript of XML Data Reduced Schema
![Page 1: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/1.jpg)
XML Data Reduced Schema
Eugenia Fernandez
IUPUI
![Page 2: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/2.jpg)
Problems with DTDs
Not expressed in XML syntax – must learn new language
Little control over data typesNot easily extensibleDoes not support XML namespaces, thus
cannot mix elements from multiple sources
![Page 3: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/3.jpg)
History of XDR
Based on a submission to the W3CSubset of Microsoft’s full XML-Data
recommendationProposal submitted in January 1998 before
XML 1.0 standard was doneIntegral part of BizTalk, an XML
vocabulary used for e-commerce
![Page 4: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/4.jpg)
XDR Schema
Root element is always SchemaRoot element always contains
– a name attribute that specifies the name of the schema
– an xmlns attribute that specifies the default namespace for the Schema element and its child elements
![Page 5: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/5.jpg)
XDR Schema Element
<Schema name="myschema"
xmlns="urn:schemas-microsoft.com:xml-data"
xmlns:dt="urn:schemas-microsoft.com:datatypes">
.
.
.
</Schema>
![Page 6: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/6.jpg)
XDR Element Syntax
<ElementType
content="{empty | textOnly | eltOnly | mixed}"
dt:type="datatype"
model="{open | closed}"
name="idref"
order="{one | seq | many}">
![Page 7: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/7.jpg)
ElementType Content
empty textOnly eltOnly
– only other elementsmixed
– mixed content model
![Page 8: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/8.jpg)
Linking an XDR Schema to an XML DocumentAdd xmlns attribute to root element
<root_element xmlns = x-schema:filename.xdr">
</root_element>
![Page 9: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/9.jpg)
Element Datatypes
boolean chardatedateTime float intnumber
string time fixed.14.4 i1, i2, i4, i8 r4, r8ui1, ui2, ui4, ui8uri
For a complete list, go to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/xsd_xdrref_5s8j.asp
![Page 10: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/10.jpg)
ElementType Model
Open– can contain other elements & attributes not
specified in the schema
Closed– cannot include elements or other content not
specified in the schema
![Page 11: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/11.jpg)
ElementType Name
name="idref"– required,– identifies the element
![Page 12: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/12.jpg)
ElementType Order
Establishes the order of the child elementsOne
– only one element of the set can be included
Seq– elements must appear in the specified sequential
order
Many– elements may appear, or not, in any order
![Page 13: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/13.jpg)
Declaring Child Elements
use element tag nested within ElementType tag with name of child element contained in type attribute
a matching ElementType must exist for the child element
<ElementType name="parent" model="closed" content="eltonly">
<element type="child"/></ElementType>
<ElementType name="child" model="closed" content="textOnly"/>
![Page 14: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/14.jpg)
Declaring Attributes
Add AttributeType element as a child of the element to which the attribute belongs– declares a type of attribute
Pair it with an attribute element – defines an attribute for that particular
element
![Page 15: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/15.jpg)
AttributeType Syntax
<AttributeType
default="default_value"
dt:type="primitive-type"
dt:values="enumerated-values"
name="idref"
required="{yes | no}">
![Page 16: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/16.jpg)
AttributeType dt:types
entity entities enumeration id idref idrefs
nmtokennmtokensnotation string
![Page 17: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/17.jpg)
Attribute Element Syntax
<attributedefault="default_value"type="attribute-type"[required="{yes | no}"] >
overrides any default provided in AttributeType
must match name attribute of previously declared AttributeType
optional if required attribute used in AttributeType
![Page 18: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/18.jpg)
Occurrence Indicators
via child elements of the element tag<element
type="element-type"
[minOccurs="{0 | 1}"]
[maxOccurs="{1 | *}"] >
optionalrequired
only once many times
![Page 19: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/19.jpg)
Attribute Length Constraints
for attributes with dt:type of string or number
via attribute of AttributeType element– dt:minLength="positive-integer"
– dt:maxLength="positive-integer"
![Page 20: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/20.jpg)
Content Groups
Establishes constraints on a group of child elements within an ElementType element<group order="{one | seq | many}"
minOccurs="{0|1}" maxOccurs="{1|*}"
<element type="ElementType"/>
<element type="ElementType"/>
<element type="ElementType"/>
</group>
![Page 21: XML Data Reduced Schema](https://reader035.fdocuments.us/reader035/viewer/2022062309/56813c64550346895da5f1cb/html5/thumbnails/21.jpg)
References
Day 5 in Sams Teach Yourself XML in 21 Days, Second Edition (Sams Publishing, 2001)