1 / 16

w3/TR/xmlschema-1 w3/TR/xmlschema-2

XML Schema. http://www.w3.org/TR/xmlschema-1 http://www.w3.org/TR/xmlschema-2 ( W3C Working Draft 17 December 1999 ) http://msdn.microsoft.com/xml/xmlguide/ schema-overview.asp. Outline. Introduction to XML Schema Defining Elements and Attributes Content Model Data Types Extensibility.

lilah
Download Presentation

w3/TR/xmlschema-1 w3/TR/xmlschema-2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML Schema http://www.w3.org/TR/xmlschema-1 http://www.w3.org/TR/xmlschema-2 (W3C Working Draft 17 December 1999) http://msdn.microsoft.com/xml/xmlguide/ schema-overview.asp EECS 684: Current Topics in Databases

  2. Outline • Introduction to XML Schema • Defining Elements and Attributes • Content Model • Data Types • Extensibility EECS 684: Current Topics in Databases

  3. Introduction • An XML Schema specifies the structure of an XML document and constrains on its content • Unlike DTD, XML Schema uses XML syntax • An XML Schema is useful for • data validation • data interchange EECS 684: Current Topics in Databases

  4. An XML Document <invoice> <billingAddress year=“2000”> <name>Alice Smith</name> <street>12 Maple Street</street> <city>Ann Arbor</city> <state>MI</state> </billingAddress> <comment>A good customer</comment> </invoice> EECS 684: Current Topics in Databases

  5. Defining & Using Types <type name = “address”> <element name = “name” type = “string” /> <element name = “street” type = “string” /> <element name = “city” type = “string” /> <element name = “state” type = “string” /> <attribute name = “year” type = “integer”/> </type> <element name = “billingAddress” type = “address” /> <element name = “comment” type = “string” /> EECS 684: Current Topics in Databases

  6. Content Model • Content • minOccurs and maxOccurs • Order • Group EECS 684: Current Topics in Databases

  7. Content • An element can contain text, other elements, a mixture of text and elements, or nothing at all • Use the content attribute • Possible values are “textOnly”, “elementOnly”, “mixed”, and “empty” • An example <type name = “street” content=“textOnly” /> EECS 684: Current Topics in Databases

  8. minOccurs and maxOccurs • Specify how many times an element can appear within another element • Use the minOccurs attribute <element name = “comment” minOccurs = “0” /> • Use the maxOccurs attribute <element name =“item” maxOccurs = “*” /> EECS 684: Current Topics in Databases

  9. Order • Specify whether sub-elements are required to appear in a certain order, and if only one sub-element can appear • Use the order attribute • Possible values are “seq”, “choice”, and “all” <type name = “address” order=“seq” /> EECS 684: Current Topics in Databases

  10. Group • Specify constraints on a specific set of sub-elements <type name = “item”> <group order = “choice”> <element type = “product”> <element type = “backOrderedProduct” /> </group> <element type = “quantity” /> <element type = “price” /> </type> • Accept order, minOccurs, and maxOccurs attributes EECS 684: Current Topics in Databases

  11. Data Types • Unlike DTD, XML Schema allows you to specify a data type for an element or an attribute • Data types indicate the format of data • Data types categorization • atomic vs. aggregate data types • primitive vs. generated data types • built-in vs. user-generated data types EECS 684: Current Topics in Databases

  12. Defining Data Types • Defining “i4” (signed 4-byte integer) from the built-in data type integer <datatype name=“i4” source=“integer”> <minInclusive value = ‘-2147483648’> <maxInclusive value = ‘2147483648’> </datatype> • minInclusive and maxInclusive facets specify the bounds of the values EECS 684: Current Topics in Databases

  13. Defining Data Types (Cont.) • Defining “amount” <datatype name = “amount” source =“decimal”> <precision value = ‘8’ /> <scale value = ‘2’ /> </datatype> • Use precision and scale facets to constrain the range of the base type. EECS 684: Current Topics in Databases

  14. Defining Data Types (Cont.) • Defining a data type which limit the values of dates to the three US holidays <datatype name = “holidays” source=“date”> <enumeration value=‘--01-01’ /> <enumeration value=‘--07-04’ /> <enumeration value=‘--12-25’ /> </datatype> • enumeration facet constrains the value space of the data type to the specified list. EECS 684: Current Topics in Databases

  15. Referencing Other Schemas • The namespace declaration • begins with “xmlns:” • followed by a “prefix” • then the URI of the other schema • Example <type name = “shipTo” xmlns:abcde=“http://ecommerce.com/a.xml”> <element type = “abcde:address” /> </type> EECS 684: Current Topics in Databases

  16. Conclusion • XML Schema allows you to • define types for elements and attributes • build a content model • define your own data types • refer to other schemas EECS 684: Current Topics in Databases

More Related