Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML Schema Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University ElementType AttributeType XML Declar.

Similar presentations


Presentation on theme: "XML Schema Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University ElementType AttributeType XML Declar."— Presentation transcript:

1

2 XML Schema Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University ElementType AttributeType XML Declar. Schema Declar.

3 Purposes of DTD  What elements should be presented?  How many of each element were required?  What kind of element content was permitted?  In what order the elements should appear? DTD is the modeling language for XML, which define the structure of a XML document. An DTD file provides the following information:

4 Components of XML Systems XML Parser (Processor) XML Application XML Document (Contents) XML DTD (Rule) Well-Formed (Syntax) Validate (Structure)

5 What is XML Schema  DTD is the original modeling language for XML. It has the following deficiencies: - DTD did not follow the regular XML syntax, thus it requires a special parser to validate. - DTD did not support much of data types. - DTD is weak in extensibility.  Schema is the new modeling language for XML,which closely follows XML syntax.

6 Problems with DTD If the DTD statement for element Quantity is: Then which of the followings syntaxes are valid? 5 _________ hello _________ 5.5 _________

7 Facts About XML Schema  Schema documents use XML syntax and are therefore XML documents.  Schemas are XML documents that conform to DTDs, which define the structure of a XML document.  Many organizations and individuals are creating DTDs and schemas for a broad range of categories (e.g., financial transactions, medical prescriptions, etc.). These collections called repositories which are often available free for download from the web.

8 Why Schema is Better?  XML Schema has Support for Data Types  XML Schemas use XML Syntax  XML Schemas Secure Data Communication  XML Schemas are Extensible  Well-Formed is not Enough

9 XML Example (1) <shiporder orderid="889923" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="shiporder.xsd"> John Smith Ola Nordmann Langgt 23 4000 Stavanger Norway

10 XML Example (2) Empire Burlesque Special Edition 1 10.90 Hide your heart 1 9.90

11 Components of Schema  XML Declaration  Comments  Schema Declaration  ElementType Declarations  AttributeType Declarations

12 Example of DTD File (1) Attribute List Declarations Element Type Declarations

13 Example of DTD File (1) Element Type Declarations

14 XML Schema (1)

15 XML Schema (2)

16 XML Declaration  Is used to provide information regarding processing such as processor (name and version), of the processor Syntax:  Examples: 

17 Comments  A place to write a note for reminding, simple documentation, or commenting out codes for debugging, etc., which will not be seen by the end users. <!-- This is a comment area -->  You can use any character inside the comment area except “--” itself  There is no limitation on the length of the comment area.

18 Selected XML Schema Data Types  boolean. 0 (false) or 1 (true).  char. A single character.  string. A series of characters.  float. A real number.  int. A whole number.  date. A date formatted as YYYY-MM-DD.  time. A time formatted as HH-MM-SS.  id. Text that uniquely identifies an element or attribute.  idref. A reference to an id.  enumeration. A series of values from which only one may be chosen.

19 Date and Time Data Types NameDescription  DateDefines a date value  dateTimeDefines a date and time value  DurationDefines a time interval  gDayDefines a part of a date - the day (DD)  gMonthDefines a part of a date - the month (MM)  gMonthDayDefines a part of a date - the month and day (MM-DD)  gYearDefines a part of a date - the year (CCYY)  gYearMonthDefines a part of a date - the year and month (CCYY-MM)  TimeDefines a time value

20 Numeric Data Types Name Description ByteA signed 8-bit integer DecimalA decimal value IntA signed 32-bit integer IntegerAn integer value LongA signed 64-bit integer negativeIntegerAn integer containing only negative values (.., -2, -1.) nonNegativeIntegerAn integer containing only non-negative values (0, 1, 2,..) nonPositiveIntegerAn integer containing only non-positive values (.., -2, -1, 0) positiveIntegerAn integer containing only positive values (1, 2,..) ShortA signed 16-bit integer unsignedLongAn unsigned 64-bit integer unsignedIntAn unsigned 32-bit integer unsignedShortAn unsigned 16-bit integer unsignedByteAn unsigned 8-bit integer

21 Advantages of XML Schema  Consistency. It follows XML syntax.  Extensibility. It includes data type and namespaces.  Exchangeability/manipulability.  Rigid specification.  Ease of use. Can use with XML API such as DOM and SAX.

22 Thank You? Any Question?


Download ppt "XML Schema Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University ElementType AttributeType XML Declar."

Similar presentations


Ads by Google