xml schema chao-hsien chu, ph.d. school of information sciences and technology the pennsylvania...

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

Author: eleanor-shields

Post on 01-Jan-2016

216 views

Category:

Documents


1 download

Embed Size (px)

TRANSCRIPT

  • XML SchemaChao-Hsien Chu, Ph.D.School of Information Sciences and TechnologyThe Pennsylvania State UniversityElementType

    AttributeTypeXML Declar.

    Schema Declar.

  • Purposes of DTDWhat 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:

  • Components of XML SystemsXMLParser(Processor)XMLApplicationXMLDocument(Contents)XMLDTD(Rule)Well-Formed(Syntax)Validate(Structure)

  • What is XML SchemaDTD 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.

  • Problems with DTDIf the DTD statement for element Quantity is: Then which of the followings syntaxes are valid?5_________hello_________5.5_________

  • Facts About XML SchemaSchema 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.

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

  • XML Example (1)

    John Smith Ola Nordmann Langgt 23 4000 Stavanger Norway

  • XML Example (2)

    Empire Burlesque Special Edition 1 10.90 Hide your heart 1 9.90

  • Components of SchemaXML DeclarationCommentsSchema DeclarationElementType Declarations AttributeType Declarations

  • Example of DTD File (1)

    Attribute ListDeclarationsElement TypeDeclarations

  • Example of DTD File (1)

    Element TypeDeclarations

  • XML Schema (1)

  • XML Schema (2)

  • XML DeclarationIs used to provide information regarding processing such as processor (name and version), of the processorSyntax:

    Examples:

  • CommentsA 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. You can use any character inside the comment area except -- itselfThere is no limitation on the length of the comment area.

  • 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.

  • Date and Time Data Types NameDescriptionDateDefines a date valuedateTimeDefines a date and time valueDurationDefines a time intervalgDayDefines 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

  • Numeric Data Types Name DescriptionByteA signed 8-bit integerDecimalA decimal valueIntA signed 32-bit integerIntegerAn integer valueLongA signed 64-bit integernegativeIntegerAn 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 integerunsignedLongAn unsigned 64-bit integerunsignedIntAn unsigned 32-bit integerunsignedShortAn unsigned 16-bit integerunsignedByteAn unsigned 8-bit integer

  • Advantages of XML SchemaConsistency. 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.

  • Thank You?Any Question?