XML Schemas and Namespaces Lecture 11, 07/10/02. BookStore.dtd.

Slides:



Advertisements
Similar presentations
XMLSchema to TTCN-3 Mapping Importing XML schema based data types into TTCN-3.
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:
1 XML DTD & XML Schema Monica Farrow G30
Copyright © [2002]. Roger L. Costello. All Rights Reserved. 1 XML Schemas (Primer)
An Introduction to XML Schema CSCI 7818 by Ming Rutar.
CSE 636 Data Integration XML Schema. 2 XML Schemas W3C Recommendation: Generalizes DTDs Uses XML syntax Two documents: structure.
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 Simple Types CSPP51038 shortcourse. Simple Types Recall that simple types are composed of text-only values. All attributes are of simple type Elements.
XML Schema Matthias Hauswirth. Agenda 4 W3C Process 4 XML Schema Requirements 4 The Specifications 4 Schema Tools.
1 XML Schemas Marco Mesiti This Presentation has been extracted from Roger L. Costello (XML Technologies Course)
ΑΝΑΠΑΡΑΣΤΑΣΗ ΓΝΩΣΗΣ ΣΤΟΝ ΠΑΓΚΟΣΜΙΟ ΙΣΤΟ XML Schema
Copyright © [2001]. Roger L. Costello. All Rights Reserved. 1 XML Schemas (Primer)
XML Schema Notes Lecture 13, 07/16/02. (see example05)
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
XML Schema – Part 1 1.Introduction to XML-Schema 2.Schema basics 3.Mechanisms (strategies) for Designing Schema 4.Creating your own Datatypes.
XML Verification Well-formed XML document  conforms to basic XML syntax  contains only built-in character entities Validated XML document  conforms.
Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka.
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.
Schema Design „Advanced XML Schema“ Lecture on Walter Kriha.
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.
Copyright © [2002]. Roger L. Costello. All Rights Reserved. 1 XML Schemas (Primer)
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)
CSE4500 Information Retrieval Systems XML Schema – Part 1.
1 XML Schemas Modified version of: Roger L. Costello XML Technologies Course (Part 1) (Structures)
Schemas1 XML Schema More Powerful. Schemas 2 DTD – Schema - Relax An XML schema is a description of a type of XML document, typically expressed in terms.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
Creating Data Schemas Presentation by Chad Borer 2/6/2006.
Ceng 520 XML Schemas IntroductionXML Schemas 2 Part 0: Introduction Why XML Schema?
1 XML Schemas (Primer) (Structures) (Datatypes)
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 –
Beginning XML 4th Edition. Chapter 5: XML Schemas.
Copyright © [2002]. Roger L. Costello. All Rights Reserved. 1 XML Schemas Modified version of: Roger L. Costello XML Technologies Course (Part 1)
New Perspectives on XML, 2nd Edition
1 XML Schemas. 2 Topics What are Schemas? NameSpaces Elements Attributes Data Types Derivations Keys.
XML. 2 XML- Some Links XML Tutorials – Some Links me=htmlhttp://
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.
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.
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.
COS 381 Day 14. Agenda Questions?? Resources Source Code Available for examples in Text Book in Blackboard
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
Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka.
XML Validation II Schemas Robin Burke ECT 360. Outline Namespaces Documents  Data types XML Schemas Elements Attributes Derived data types RELAX NG.
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 Validation II Advanced DTDs + Schemas Robin Burke ECT 360.
Lecture 0 W3C XML Schema. Topics Status Motivation Simple type vs. complex type.
Copyright © [2001]. Roger L. Costello. All Rights Reserved. 1 XML Schemas (Primer)
Agenda 1.WSDL & XML Schema Astronomicko-geofyzikálne observatórium, Modra An Order.
XML Schema – Simple Type Web site:
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.
1 XML Schemas (Primer) (Structures) (Datatypes)
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
THE DATATYPES OF XML SCHEMA A Practical Introduction
Presentation transcript:

XML Schemas and Namespaces Lecture 11, 07/10/02

BookStore.dtd

<xsd:schema xmlns:xsd=" targetNamespace=" xmlns=" elementFormDefault="qualified"> This is referencing a Book element declaration. The Book in what namespace? Since there is no namespace qualifier it is referencing the Book element in the default namespace, which is the targetNamespace! Thus, this is a reference to the Book element declaration in this schema. The default namespace is which is the targetNamespace!

<schema xmlns=" targetNamespace=" xmlns:bk=" elementFormDefault="qualified"> (see example02) Note that is the default namespace. Consequently, there are no namespace qualifiers on - schema - element - complexType - sequence - string

<schema xmlns=" targetNamespace=" xmlns:bk=" elementFormDefault="qualified"> Here we are referencing a Book element. Where is that Book element defined? In what namespace? The bk: prefix indicates what namespace this element is in. bk: has been set to be the same as the targetNamespace.

<!ATTLIST Book Category (autobiography | non-fiction | fiction) #REQUIRED InStock (true | false) "false" Reviewer CDATA " "> BookStore.dtd

(see example08)

"Instance documents are required to have the Category attribute (as indicated by use="required"). The value of Category must be either autobiography, non-fiction, or fiction (as specified by the enumeration facets)." Note: attributes can only have simpleTypes (i.e., attributes cannot have child elements).

… … Local attribute declaration. Use the "use" attribute here. Global attribute declaration. Must NOT have a "use" ("use" only makes sense in the context of an element)

Summary of Declaring Attributes (two ways to do it) required optional prohibited Do not use the "use" attribute if you use either default or fixed. xsd:string xsd:integer xsd:boolean... … 1 2

use --> use it only with Local Attribute Declarations The "use" attribute only makes sense in the context of an element declaration. Example: "for each Book element, the Category attribute is required". When declaring a global attribute do not specify a "use"

Notes about Attributes The attribute declarations always come last, after the element declarations. The attributes are always with respect to the element that they are defined (nested) within. … "bar and boo are attributes of foo"

These attributes apply to the element they are nested within (Book) That is, Book has three attributes - Category, InStock, and Reviewer.

or ? When do you use the complexType element and when do you use the simpleType element? –Use the complexType element when you want to define child elements and/or attributes of an element –Use the simpleType element when you want to create a new type that is a refinement of a built- in type (string, date, gYear, etc)

complexContent versus simpleContent With complexContent you extend or restrict a complexType With simpleContent you extend or restrict a simpleType … X must be a complexType … Y must be a simpleType versus Do Lab 8.b, 8.c

"I hereby declare a new type called ISBNType. It is a restricted form of the string type. Elements declared of this type must conform to one of the following patterns: - First Pattern: 1 digit followed by a dash followed by 5 digits followed by another dash followed by 3 digits followed by another dash followed by 1 more digit, or - Second Pattern: 1 digit followed by a dash followed by 3 digits followed by another dash followed by 5 digits followed by another dash followed by 1 more digit, or - Third Pattern: 1 digit followed by a dash followed by 2 digits followed by another dash followed by 6 digits followed by another dash followed by 1 more digit."

Element with Simple Content and Attributes Example. Consider this: 5440 The elevation element has these two constraints: - it has a simple (integer) content - it has an attribute called units How do we declare elevation? (see next slide)

1. elevation contains an attribute. - therefore, we must use 2. However, elevation does not contain child elements (which is what we generally use to indicate). Instead, elevation contains simpleContent. 3. We wish to extend the simpleContent (an integer) with an attribute

elevation - use Stronger Datatype In the declaration for elevation we allowed it to hold any integer. Further, we allowed the units attribute to hold any string. Let's restrict elevation to hold an integer with a range ,000 and let's restrict units to hold either the string "feet" or the string "meters"

Expressing Alternates DTD: XML Schema: <xsd:schema xmlns:xsd=" targetNamespace=" xmlns=" elementFormDefault="qualified"> (see example10) Note: the choice is an exclusive-or, that is, transportation can contain only one element - either train, or plane, or automobile.

Expressing Repeatable Choice <xsd:schema xmlns:xsd=" targetNamespace=" xmlns=" elementFormDefault="qualified"> DTD: XML Schema: Notes: 1. An element can fix its value, using the fixed attribute. 2. When you don't specify a value for minOccurs, it defaults to "1". Same for maxOccurs. See the last example (transportation) where we used a element with no minOccurs or maxOccurs. (see example 11)

fixed/default Element Values When you declare an element you can give it a fixed or default value. –Then, in the instance document, you can leave the element empty. … 0 or equivalently: … red or equivalently:

Expressing Any Order <xsd:schema xmlns:xsd=" targetNamespace=" xmlns=" elementFormDefault="qualified"> XML Schema: Problem: create an element, Book, which contains Author, Title, Date, ISBN, and Publisher, in any order (Note: this is very difficult and ugly with DTDs). means that Book must contain all five child elements, but they may occur in any order. (see example 12)

Empty Element <xsd:schema xmlns:xsd=" targetNamespace=" xmlns=" elementFormDefault="qualified"> Schema: Instance doc (snippet): Do Lab 10 DTD: (see example 13)

Built-in Datatypes Primitive Datatypes –string –boolean –decimal –float –double –duration –dateTime –time –date –gYearMonth –gYear –gMonthDay Atomic, built-in –"Hello World" –{true, false, 1, 0} –7.08 – 12.56E3, 12, 12560, 0, -0, INF, -INF, NAN – P1Y2M3DT10H30M12.3S – format: CCYY-MM-DDThh-mm-ss – format: hh:mm:ss.sss – format: CCYY-MM-DD – format: CCYY-MM – format: CCYY – format: --MM-DD Note: 'T' is the date/time separator INF = infinity NAN = not-a-number

Built-in Datatypes (cont.) Derived types –negativeInteger –long –int –short –byte –nonNegativeInteger –unsignedLong –unsignedInt –unsignedShort –unsignedByte –positiveInteger Subtype of primitive datatype – negative infinity to -1 – to – to – to – -127 to 128 – 0 to infinity – 0 to – 0 to – 0 to –0 to 255 –1 to infinity Note: the following types can only be used with attributes : ID, IDREF, IDREFS, NMTOKEN, NMTOKENS, ENTITY, and ENTITIES.

Built-in Datatypes (cont.) Derived types –normalizedString –token –language –IDREFS –ENTITIES –NMTOKEN –NMTOKENS –Name –NCName –ID –IDREF –ENTITY –integer –nonPositiveInteger Subtype of primitive datatype – A string without tabs, line feeds, or carriage returns – String w/o tabs, l/f, leading/trailing spaces, consecutive spaces –any valid xml:lang value, e.g., EN, FR,... –must be used only with attributes –part (no namespace qualifier) –must be used only with attributes –456 –negative infinity to 0