Kbase 21204: Importance of XML Schema.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  23/06/2004 |
|
Status: Unverified
GOAL:
The importance of the XML Schema Explained
FACT(s) (Environment):
Progress 9.1C
XML
FIX:
Importance of XML Schema:
In his www opening keynote. Tim Berners Lee announced that W3C XML Schema is now a W3C recommendation and should be considered as one of the foundations of XML, together with XML 1.0 and Namespaces in XML. (May the first 2001).
XML Schema strengths:
XML Schema:
- Used to create Valid XML documents
- Uses Strong DATATYPES!
- Language is XML
- Lots and Lots of Datatypes:
(String, integer, Boolean, native-integer, double, long, decimal, short, float, byte, date and time, binary) and more.
XML Schema weakness
- Complexity: W3C Recommendation is large and lots of Cross-References
- W3C Recommendations just passed, Real world is just starting to use it.
- Vendors still proposing other schema solutions. (XDR, DCD, SOX, DDML).
XML Schema Fragment: (Datatype Various)
<xsd:element name="comment" type="xsd:string"/>
<xsd:attribute name="orderDate" type="xsd:date"/>
<xsd:element name="quantity" type="xsd:positiveInteger">
<xsd:element name="USPrice" type="xsd:decimal"/>
Creating Datatypes/Example of Range
XML Schema Fragment.
<xsd:simpleType name= TodaysTemp">
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="-200"/>
<xsd:maxInclusive value= 150"/>
</xsd:restriction>
</xsd:simpleType>
Patterns:
XML Schema Fragment.
<xsd:simpleType name="SKU">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3}-[A-Z]{2}“/>
</xsd:restriction>
</xsd:simpleType>
Simple Type:
XML Document Fragment:
<InvoiceNo>12344321</InvoiceNo>
<ProductID>J123321</ProductID>
DTD Fragment
<!ELEMENT InvoiceNo (#PCDATA)>
<!ELEMENT ProductID (#PCDATA)>
XML Schema Fragment
<element name=‘InvoiceNo’ type=‘positive-integer’/>
<element name=‘ProductID’ type=‘ProductCode’/>
<simpleType name=‘ProductCode’ base=‘string’>
<pattern value=‘[A-Z]{1}d{6}’/>
</simpleType>
Complex Type:
XML Document Fragment:
<Book>
<Title>XML Schema 101</Title>
<Author>Some Author</Author>
</Book>
DTD Fragment:
<!ELEMENT Book (Title, Author)>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Author (#PCDATA)>
XML Schema Fragment
<element name=‘InvoiceNo’ type=‘BookType’/>
<complexType name=‘BookType’>
<element name=‘Title’ type=‘string’/>
<element name=‘Author’ type=‘string’/>
</complexType>
Namespaces:
XML Schema Fragment:
<xsd:schema targetNamespace=‘http://www.SampleStore.com/Account’
xmlns:xsd=‘http://www.w3.org/2001/XMLSchema’
xmlns:Acc=‘http://www.SampleStore.com/Account’>
<xsd:element name=‘InvoiceNo’ type=‘xsd:positive-integer’/>
<xsd:element name=‘ProductID’ type=‘Acc:ProductCode’/>
<xsd:simpleType name=‘ProductCode’ base=‘xsd:string’>
<xsd:pattern value=‘[A-Z]{1}d{6}’/>
</xsd:simpleType>
XML Schema and Progress 9.1C
- Supports XML Schema
- Annotates a schema using non-native attributes:
Provides information on mapping instance data to SmartDataObject and SmartBusinessObjects.