Consultor Eletrônico



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}&#8220;/>
</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=&#8216;InvoiceNo&#8217; type=&#8216;positive-integer&#8217;/>
<element name=&#8216;ProductID&#8217; type=&#8216;ProductCode&#8217;/>
<simpleType name=&#8216;ProductCode&#8217; base=&#8216;string&#8217;>
<pattern value=&#8216;[A-Z]{1}d{6}&#8217;/>
</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=&#8216;InvoiceNo&#8217; type=&#8216;BookType&#8217;/>
<complexType name=&#8216;BookType&#8217;>
<element name=&#8216;Title&#8217; type=&#8216;string&#8217;/>
<element name=&#8216;Author&#8217; type=&#8216;string&#8217;/>
</complexType>


Namespaces:

XML Schema Fragment:
<xsd:schema targetNamespace=&#8216;http://www.SampleStore.com/Account&#8217;
xmlns:xsd=&#8216;http://www.w3.org/2001/XMLSchema&#8217;
xmlns:Acc=&#8216;http://www.SampleStore.com/Account&#8217;>
<xsd:element name=&#8216;InvoiceNo&#8217; type=&#8216;xsd:positive-integer&#8217;/>
<xsd:element name=&#8216;ProductID&#8217; type=&#8216;Acc:ProductCode&#8217;/>
<xsd:simpleType name=&#8216;ProductCode&#8217; base=&#8216;xsd:string&#8217;>
<xsd:pattern value=&#8216;[A-Z]{1}d{6}&#8217;/>
</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.