advertisement

XML schema part1 EN

60 %
40 %
advertisement
Information about XML schema part1 EN
Entertainment

Published on December 5, 2007

Author: Gavril

Source: authorstream.com

advertisement

MULTIMEDIA DOCUMENTS XML Schema (Part 1):  MULTIMEDIA DOCUMENTS XML Schema (Part 1) Christine Vanoirbeek EPFL – IC – CGC Bâtiment BC (Station 14) 1015 LAUSANNE christine.vanoirbeek@epfl.ch About DTDs:  About DTDs DTDs aim at defining document classes; they specify The type of authorized elements in a document instance, as well as potential attributes associated to those elements The organization rules of elements 2 constructors (sequence and choice) 3 occurrence indicators (optional element, optional element potentially repeated, mandatory element potentially repeated) DTDs:  DTDs An example <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT recipe (title, comment*, item+, picture?)> <!ATTLIST recipe nbPers CDATA #REQUIRED difficulty (easy | medium | difficult) #IMPLIED > <!ELEMENT item (header?, ((ingredient+, step+) | (ingredient+, step)+))> <!ATTLIST item name ID #IMPLIED > <!ELEMENT ingredient (#PCDATA)> <!ATTLIST ingredient quant CDATA #REQUIRED unit CDATA #IMPLIED name CDATA #IMPLIED > <!ELEMENT step (#PCDATA | link)*> <!ATTLIST step duration CDATA #IMPLIED> <!ELEMENT title (#PCDATA)> <!ELEMENT header (#PCDATA)> <!ELEMENT comment (#PCDATA)> <!ELEMENT picture EMPTY> <!ATTLIST picture source CDATA #REQUIRED format (jpeg | png) #IMPLIED > <!ELEMENT link (#PCDATA)> <!ATTLIST link ref IDREF #IMPLIED> DTDs:  DTDs Some comments Global structure of the recipe 2 structures are proposed for « item »; they take into consideration 2 frequent types of recipes [1] [2] Attributes (role, type, optional or mandatory, assignment of the value) Empty elements Links Why XML schema?:  Why XML schema? From publishing to document processing! Typed elements and attributes number date boolean … Hierarchy of types (similarly to programming languages) Why XML schema?:  Why XML schema? The DTDs only offer very basic possibilities for reusing definition of elements Such as,by example: address, references, etc. An object oriented approach supporting the specialization and extension of elements definition <!ENTITY % base "(deepDish | thinCrust | stuffed)" > <!ENTITY % topping "(sausage | mushroom | pepper | ...)"> <!ELEMENT pizza - - (%base, cheese & tomato, (%topping;)* )> Why XML schema?:  Why XML schema? Using DTDs, 3 occurrence indicators are available ? * + Using XML schema, it is possible to mention explicitely the minimum and maximum number of occurrences Example: specification of a limited number of keywords in a paper Why XML schema?:  Why XML schema? DTDs make use of a specific syntax, it implies two major drawbacks Existing XML-based tools (validation, transformation, etc.) may not be used Namespaces are not supported The XML schema language is based on the XML syntax Objective: to propose a unified paradigm Namespaces:  Namespaces A simple XML schema <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="recipe"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="comment" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="item" type="xs:string" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Namespaces:  Namespaces How to deal with several languages inside an XML document? element complexType schema sequence http://www.w3.org/2001/XMLSchema string integer boolean Recipe Title Comment http://www.recipes.org The XML schema vocabulary allows a document class designer to specify its own vocabulary Item Main components of an XML Schema:  Main components of an XML Schema Prologue <?xml version="1.0" encoding="UTF-8"?> Schema root <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> Definition of elements Complex elements (subdivided into sub-elements) Simple elements (potentially typed) Mixed elements (text + tagged elements) Empty elements Element of « any » type Definition of structured elements:  Definition of structured elements The name of an element is specified via the “name” attribute associated to the XML schema “element” The composition rule is specified via the child element “complexType”; it may include 3 constructors sequence choice all The number of occurrences are specified by the attributes “minOccurs” et “maxOccurs” Sequence:  Sequence <xs:element name="recipe"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="comment" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="item" maxOccurs="unbounded"/> <xs:element name="picture" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> Choice:  Choice <xs:element name="item" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="header" type="xs:string" minOccurs="0"/> <xs:choice> <xs:sequence> <xs:element name="ingredient" type="xs:string“ maxOccurs="unbounded"/> <xs:element name="step" type="xs:string" maxOccurs="unbounded"/> </xs:sequence> <xs:choice maxOccurs="unbounded"> <xs:element name="ingredient" type="xs:string"/> <xs:element name="step" type="xs:string"/> </xs:choice> </xs:choice> </xs:sequence> </xs:complexType> </xs:element> All:  All <xs:element name="Description"> <xs:complexType> <xs:all> <xs:element name="country" type="xs:string"/> <xs:element name="originalTitle" type="xs:string"/> <xs:element name="author" type="xs:string"/> </xs:all> </xs:complexType> </xs:element> Definition of the content models:  Definition of the content models Local definition <xs:element name="Description"> <xs:complexType> <xs:all> <xs:element name="country" type="xs:string"/> <xs:element name="originalTitle" type="xs:string"/> <xs:element name="author" type="xs:string"/> </xs:all> </xs:complexType> </xs:element> Definition of the content models:  Definition of the content models Global definition <xs:element name="recipe"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="comment" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element ref="item" maxOccurs="unbounded"/> <xs:element name="picture" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="item"> <xs:complexType> … </xs:complexType> </xs:element> Definition of the content models:  Definition of the content models Use of an explicit type declaration <xs:complexType name="itemType"> … </xs:complexType> <xs:element name="recipe"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="comment" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="item" type="itemType"/> <xs:element name="picture" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> Definition of the content models (summary):  Definition of the content models (summary) Local definitions Global definitions Benefit: definitions are factorized Use of an explicit type declaration Object-oriented mechanisms may be used Important remark: the use of one or another way to define the elements is not reflected in the document instance. Definition of simple types:  Definition of simple types Preliminary remark Lexical space Exemple: float (2.57 , +2.57 , .257E1) Value space Hierarchy of predefined types:  Hierarchy of predefined types Text Numbers Time related types Type derivation:  Type derivation Restriction Limits the value range of the base type; the semantic is not affected List Specify the content type of a simple element as a list of values of one type Union The value may be specified using alternate type candidates Restriction:  Restriction Use of facets <xs:simpleType name =”myInteger”> <xs:restriction base="xs:integer"> <xs:minInclusive value="-2"/> <xs:maxExclusive value="5"/> </xs:restriction> </xs:simpleType> List:  List <xs:simpleType name=”integerListType”> <xs:list itemType=”xs:integer”> </xs:list> </xs:simpleType> <integerList>1 -25000 1000</integerList> Union:  Union <xs:simpleType name=”integerOrDate”> <xs:union memberTypes=”xs:integer xs:date”/> </xs:simpleType> Definition of attributes:  Definition of attributes Example 1 <xs:element name="picture" minOccurs="0"> <xs:complexType> <xs:attribute name="source" type="xs:anyURI"/> </xs:complexType> </xs:element> Definition of attributes:  Definition of attributes Example 2 <xs:element name="recipe"> <xs:complexType> ... <xs:attribute name="difficulty"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="easy"/> <xs:enumeration value="medium"/> <xs:enumeration value="difficult"/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:complexType> </xs:element> Definition of attributes:  Definition of attributes Occurrences and default value <xs:element name="recipe"> <xs:complexType> ... <xs:attribute name="difficulty“ use =“optional” > <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="easy"/> <xs:enumeration value="medium"/> <xs:enumeration value="difficult"/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:complexType> </xs:element> Group of attributes:  Group of attributes xs:attributeGroup name="pictureFeatures"> <xs:attribute name="source" type="xs:anyURI" use="required"/> <xs:attribute name="format" use="required"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="jpeg"/> <xs:enumeration value="png"/> <xs:enumeration value="gif"/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:attributeGroup> <xs:element name="picture" minOccurs="0"> <xs:complexType> <xs:attributeGroup ref="pictureFeatures"/> </xs:complexType> </xs:element> Example of recipe (1):  Example of recipe (1) Example of recipe (2):  Example of recipe (2)

#required presentations

Add a comment

Related presentations

Related pages

XML Schema Part 1: Structures Second Edition

Specifies the XML Schema definition language, which offers facilities for describing the structure and constraining the contents of XML 1.0 documents. (W3C ...
Read more

XML Schema Part 1: Structures - World Wide Web Consortium

XML Schema: Structures specifies the XML Schema definition language, which offers facilities for describing the structure and constraining the contents of ...
Read more

Schema for Web Services — Part I: Basic Datatypes

En; 中文; 日本; Fr; Br ... XML message exchange is the basis of most varieties of web services, ... The W3C's XML Schema definition language ...
Read more

XML.com

An easy-to-read introduction to XML Schema, a W3C XML language for describing and constraining the content of XML documents.
Read more

Article: Schema for Web Services – Part I: Basic Datatypes

En; 中文; 日本; Fr; Br ... He continues to look in detail at XML Schema numeric types, time-related values, and references. For each of these, ...
Read more

XML Schema Primer - Oracle Help Center

XML Schema and Oracle XML DB. Support for the Worldwide Web Consortium (W3C) XML Schema Recommendation is a key feature in Oracle XML DB. XML Schema ...
Read more

XML Schema Teil 1: Strukturen - edition W3.de

Zusammenfassung. XML Schema: Strukturen spezifiziert die XML Schema-Definitionssprache, mit der die Struktur von XML 1.0 Dokumenten beschrieben und ...
Read more

XML.com: Using W3C XML Schema

The W3C XML Schema Definition Language is an XML language for describing and constraining the content of XML documents. W3C XML Schema is a W3C ...
Read more

Xml Schema - Free downloads and reviews - CNET Download.com

xml schema free download - Excel 2003 Samples: Expense Report and XML Schema, Office XP: XML Schema for Smart Tag Lists, 2007 Office System: XML Schema ...
Read more

Web Science/Part1: Foundations of the web/Web content ...

Web Science/Part1: Foundations of the web/Web content/Working with XML. From Wikiversity ... Understand that HTML is just a special dialect of XML;
Read more