Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka.

Slides:



Advertisements
Similar presentations
Module 3 XML Schema.
Advertisements

Managing XML and Semistructured Data Lecture 12: XML Schema Prof. Dan Suciu Spring 2001.
4 XML Schema.
1 Web Data Management XML Schema. 2 In this lecture XML Schemas Elements v. Types Regular expressions Expressive power Resources W3C Draft:
XML 6.5 XML Schema (XSD) 6. What is XML Schema? The origin of schema  XML Schema documents are used to define and validate the content and structure.
1 XML DTD & XML Schema Monica Farrow G30
SDPL 2003Notes 2: Document Instances and Grammars1 2.5 XML Schemas n A quick introduction to XML Schema –W3C Recommendation, May 2, 2001: »XML Schema Part.
CSE 636 Data Integration XML Schema. 2 XML Schemas W3C Recommendation: Generalizes DTDs Uses XML syntax Two documents: structure.
XML Schema Definition Language
2/9/00 EECS 684: Current Topics in Databases1 ( W3C Working Draft 17 December 1999 )
XML Schemas Lecture 10, 07/10/02. Acknowledgements A great portion of this presentation has been borrowed from Roger Costello’s excellent presentation.
XML Schema Matthias Hauswirth. Agenda 4 W3C Process 4 XML Schema Requirements 4 The Specifications 4 Schema Tools.
XML Schemas and Namespaces Lecture 11, 07/10/02. BookStore.dtd.
Document Content Description for XML, Version 1.0 By Tim Bray, Charles Frankston and Ashok Malhotra EECS 684 Presentation by Calvin Ang.
1 Week5 – Schema Why Schema? Schemas vs. DTDs Introduction – W3C vs. Microsoft XDR Schema, How To? Element Types – Simple vs. Complex Attributes Restrictions/Facets.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
Introduction to XML Schema Winter Sources XML Schema Part 1: Structures W3C Recommendation 2 May 2001,
1 Print your own copy If you bring it along, hand in with your exam script Do not write anything extra or you will be penalized Student Name: Student Number:
Unit 4 – XML Schema XML - Level I Basic.
Introduction to XML This material is based heavily on the tutorial by the same name at
17 Apr 2002 XML Schema Andy Clark. What is it? A grammar definition language – Like DTDs but better Uses XML syntax – Defined by W3C Primary features.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
XML for E-commerce II Helena Ahonen-Myka. XML processing model n XML processor is used to read XML documents and provide access to their content and structure.
SDPL 2002Notes 2: Document Instances and Grammars1 2.5 XML Schemas n A quick introduction to XML Schema –W3C Recommendation, May 2, 2001: »XML Schema Part.
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
IS432 Semi-Structured Data Lecture 3: XSchema Dr. Gamal Al-Shorbagy.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Schema 1 Lecturer.
XML Schema Vinod Kumar Kayartaya. What is XML Schema?  XML Schema is an XML based alternative to DTD  An XML schema describes the structure of an XML.
Chapter 4: Document Type Definitions. Chapter 4 Objectives Learn to create DTDs Validate an XML document against a DTD Use DTDs to create XML documents.
1 XML Schemas. 2 Useful Links Schema tutorial links:
Dr. Azeddine Chikh IS446: Internet Software Development.
Copyright © [2001]. Roger L. Costello. All Rights Reserved. 1 XML Schemas (Primer)
Neminath Simmachandran
XML and friends Part 2 - XML Schema ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Schema 2 Lecturer.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
SDPL 2005Notes 2.5: XML Schemas1 2.5 XML Schemas n Short introduction to XML Schema –W3C Recommendation, 1 st Ed. May, 2001; 2 nd Ed. Oct, 2004: »XML Schema.
New Perspectives on XML, 2nd Edition
XML Schema. Why Schema? To define a class of XML documents Serve same purpose as DTD “Instance document" used for XML document conforming to schema.
An OO schema language for XML SOX W3C Note 30 July 1999.
XML – Part III. The Element … This type of element either has the element content or the mixed content (child element and data) The attributes of the.
An Introduction to XML Sandeep Bhattaram
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 5 XML Schema (Based on Møller and Schwartzbach,
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
XML 2nd EDITION Tutorial 4 Working With Schemas. XP Schemas A schema is an XML document that defines the content and structure of one or more XML documents.
1 Tutorial 14 Validating Documents with Schemas Exploring the XML Schema Vocabulary.
Tutorial 13 Validating Documents with Schemas
1 © The ATHENA Consortium. XML, eXtensible Markup Language (1) The format for structured information exchange. –Primary structuring is containment.
Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka.
XML Schema (W3C) Thanks to Jussi Pohjolainen TAMK University of Applied Sciences.
Primer on XML Schema CSE 544 April, XML Schemas Generalizes DTDs Uses XML syntax Two parts: structure and datatypes Very complex –criticized –alternative.
Introduction to XML Schema John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: (x2073)
CSE 6331 © Leonidas Fegaras XML Schema 1 XML Schema Leonidas Fegaras.
XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML Schema Definition (XSD). Definition of a Schema It is a model for describing the structure and content of data The XML Schema was developed as a content.
Lecture 0 W3C XML Schema. Topics Status Motivation Simple type vs. complex type.
CITA 330 Section 4 XML Schema. XML Schema (XSD) An alternative industry standard for defining XML dialects More expressive than DTD Using XML syntax Promoting.
Web Services: Principles & Technology Slide 3.1 Chapter 3 Brief Overview of XML COMP 4302/6302.
4 Copyright © 2004, Oracle. All rights reserved. Validating XML by Using XML Schema.
SDPL : XML Schemas1 2.5 XML Schemas n Short introduction to XML Schema –W3C Recommendation, 1 st Ed. May, 2001; 2 nd Ed. Oct, 2004: »XML Schema.
MSc in Communication Sciences Program in Technologies for Human Communication Davide Eynard Facoltà di scienze della comunicazione Università.
XML Schemas Dr. Awad Khalil Computer Science Department AUC.
Introduction to XML Schema DoD Users Group Tutorial on XML and Science
X-Informatics: I-400 and I-590 XML Schema
XML Schema Primer Seong Jong Choi Multimedia Lab.
New Perspectives on XML
Presentation transcript:

Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka

2 XML Namespaces An XML document may contain multiple markup vocabularies reuse of existing markup, e.g. including HTML markup in some document type An XML namespace is a collection of names, identified by a URI reference, which are used in XML documents as element and attribute names

3 Author A writes a document: Macmillan ABC News

4 Author B adds some rating…. Macmillan 5 stars ABC News 3 stars

5 Also Author C wants to add some rating... Macmillan G ABC News PG

6 Author D would like to combine the documents... Macmillan 5 stars G ABC News 3 stars PG

7 Which rating? -> different names Macmillan 5 stars G ABC News 3 stars PG

8 Namespaces give a disciplined method for naming <references xmlns:qa=” xmlns:pa=” xmlns=” Macmillan 5 stars G...

9 Namespaces xmlns:qa=” qa: prefix the namespace a unique name (URI guarantees): no need to retrieve anything from the address xmlns=” the default namespace elements without prefixes belong to this namespace references, name, link

10 Namespaces qa:rating a qualified name (Qname) scoping: The namespace is valid for the element where it is declared and all the elements within its content

11 Scoping Macmillan G ABC News 3 stars

12 Attributes if an attribute is qualified in an instance (= with namespace prefix), its name is unique in that namespace unqualified in an instance, the combination of the attribute name with the element’s type and namespace name uniquely identifies the attribute E.g. the “href” attribute above is identified by “link”, and ”href” note: an element can have only one attribute with the same name

13 Namespaces and DTD XML 1.0 DTDs are not namespace-aware all the elements and attributes that are in some namespace have to be declared using the corresponding prefix for elements with prefix ’pre’ : an attribute ’xmlns:pre’ has to be declared

14 Namespaces and DTD <!DOCTYPE ref:references [ <!ELEMENT ref:references (ref:name, ref:link, (pa:rating | qa:rating)*)+> ]>

15 Modularity with DTDs: external and internal subsets external and internal subset make up the DTD; internal has higher precedence syntax: [ ]> internal subset may declare new elements (with attributes) or new attributes for existing elements XML Schema is namespace-aware -> more modularity

16 XML Schema DTDs have drawbacks: DTDs have drawbacks: they can only define the element structure and attributes they cannot define any database-like constraints for elements: Value (min, max, etc.) Type (integer, string, etc.) DTDs are not written in XML and cannot thus be processed with the same tools as XML documents, XSL(T), etc. difficult to combine different vocabularies (namespaces) XML Schemas XML Schemas: are written in XML avoid most of the DTD drawbacks

17 XML Schema XML Schema Part 1: Structures: XML Schema Part 1: Structures: Element structure definition as with DTD: Elements, attributes, also enhanced ways to control structures XML Schema Part 2: Datatypes: XML Schema Part 2: Datatypes: Primitive datatypes (string, boolean, float, etc.) Derived datatypes from primitive datatypes (time, recurringDate) Constraining facets for each datatype (minLength, maxLength, pattern, precision, etc.) The following is based on: The following is based on: XML Schema Part 0: Primer ( )

18 Reminder: DTD declarations

19 Alice Smith 123 Maple Street Mill Valley CA A sample document

20 Robert Smith 8 Oak Avenue Old Town PA Hurry, my lawn is going wild! Continues...

21 Lawnmower Lawnmower Confirm this is electric Confirm this is electric Baby Monitor Baby Monitor </purchaseOrder> … continues

22 DTD

23 DTD continues <!ELEMENT item (productName, quantity, USPrice, comment?, shipDate?)>

24 In this part... complex vs. simple types shared types and element declarations occurrence constraints (elements/attributes) global vs. local (types/elements/attr.) simple types special cases for element content

25 Complex and simple types Schema defines types for elements and attributes complex types: allow elements in their content and may have attributes simple types: cannot have element content and cannot have attributes elements can have complex or simple types, attributes can have simple types

26 XML Schema: structure <xsd:schema xmlns:xsd=” … … …

27 USAddress type <xsd:attribute name=”country” type=”xsd:NMTOKEN” fixed=”US” />

28 PurchaseOrderType

29 Shared types, references element declarations for ”shipTo” and ”billTo” associate different element names with the same complex type attribute declarations must reference simple types element ”comment” declared on the top level of the schema (here reference only)

30 Occurrence constraints minOccurs, maxOccurs (defaults: 1) minOccurs: minimun number of times an element may appear element is optional, if minOccurs = 0 maxOccurs: maximum number of times an element may appear attributes may appear once or not at all

31 Attributes use, default and fixed (in attribute declarations) Attribute ”use” is used in an attribute declaration to indicate whether the attribute is ’required’, ’optional’ or ’prohibited’ default value may be provided if ’optional’ is set if the instance does not give the value the default is used

32 Attributes use, default and fixed (in attribute declarations) Attribute ”fixed” the value of the attribute is the value of ”fixed” (if attribute not present -> value=37) (attribute has to be present and its value must be 37)

33 Global vs. local named types vs. anonymous types global elements/attributes vs. local elements/attributes

<xsd:element name="shipDate" type="xsd:date” <xsd:element name="shipDate" type="xsd:date” minOccurs="0"/> minOccurs="0"/> </xsd:complexType>

35 Anonymous type definitions Schemas can be constructed by defining sets of named types such as PurchaseOrderType on the top level and then declaring elements such as purchaseOrder if a type is used only once, it is more compactly defined as an anonymous type

36 Anonymous type definitions You can define anonymous types by the lack of ’type=’ in an element declaration and by the presence of an unnamed (simple or complex) type definition following the element name see the Items type definition

37 Global elements and attributes Global elements and attributes have declarations that appear as the children of the schema element global elements and attributes can be referenced in one or more declarations using the ”ref” attribute

38 Global elements and attributes global elements can appear in the instance document in the place where they have been referenced, or at the top level of the document global declarations cannot contain references global declarations cannot contain occurrence constraints

39 Local elements/attributes local elements and attributes are declared within a type definition make context-sensitive structures possible (not possible with DTDs) Of Mice and Men … Mrs. …

40 Simple types built-in types, derived types facets list types, union types

41 Simple types Built-in types e.g. string, integer, positiveInteger, decimal, float, boolean, time, date, recurringDay, uriReference, language, ID, IDREF must have XML Schema namespace prefix derived types derived from built-in and other derived types by defining restrictions to the base type each base type has a set of facets that can be used for restrictions

42 Facets XML Schema defines 15 facets e.g. string has facets: length, minLength, maxLength, pattern, enumeration e.g. integer has facets: pattern, enumeration, maxInclusive, maxExclusive, minInclusive, minExclusive, precision

43 Defining a new type of integer New type whose range of values is between and 99999

44 Patterns </xsd:simpleType> ”three digits followed by a hyphen followed by two upper- case ASCII letters”

45 Enumeration facet Limits values to a set of distinct values

46 List types List types are comprised of sequences of atomic types instance:

47 Union types Type can be chosen from a set: CA

48 Special cases for element content simple type content + attributes mixed content empty content anyType

49 Simple type content + attributes How to define attributes for elements with simple type content? In instance: in the sample schema: comes close but simple types cannot have attributes -> a complex type has to be defined

50 Simple type content + attributes New complex type is derived from type ’decimal’

51 Mixed content Element contains both character data and subelements Dear Mr. Robert Smith. Your order of 1 Baby Monitor shipped from our warehouse on …

52 Mixed content …

53 Empty content Assume we want the internationalPrice element to have both the unit of currency and the price as attribute values: i.e. the element has no content solution: no elements defined in the content model

54 Empty content <xsd:element name=”internationalPrice”

55 Shorthand for empty complex type <xsd:element name=”internationalPrice”

56 anyType The anyType seen in the definition for an empty content model represents an abstraction which is the base type from which all simple and complex types are derived anyType does not constrain its content in any way can be used like other types is a default if no type is specified