XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.

Slides:



Advertisements
Similar presentations
XML Schema Heewon Lee. Contents 1. Introduction 2. Concepts 3. Example 4. Conclusion.
Advertisements

XML: Extensible Markup Language
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 DTD (Document Type Definition) Imposing Structure on XML Documents (W3Schools on DTDs)W3Schools on DTDs.
1 XML DTD & XML Schema Monica Farrow G30
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
CSE 636 Data Integration XML Schema. 2 XML Schemas W3C Recommendation: Generalizes DTDs Uses XML syntax Two documents: structure.
A Simple Schema Design. First Schema Design Being a Dog Is a Full-Time Job Charles M. Schulz Snoopy Peppermint Patty extroverted beagle Peppermint.
XML Schemas Lecture 10, 07/10/02. Acknowledgements A great portion of this presentation has been borrowed from Roger Costello’s excellent presentation.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
XML Schemas and Namespaces Lecture 11, 07/10/02. BookStore.dtd.
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
1 XML Schema Information Retrieval Systems Maria Indrawan 2003.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
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.
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
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Schemas Ellen Pearlman Eileen Mullin Programming the Web Using XML.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
Li Tak Sing COMPS311F. XML Schemas XML Schema is a more powerful alternative to DTD to describe XML document structures. The XML Schema language is also.
XP 1 DECLARING A DTD A DTD can be used to: –Ensure all required elements are present in the document –Prevent undefined elements from being used –Enforce.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
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.
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.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
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.
XSD Presented by Kushan Athukorala. 2 Agenda XML Namespaces XML Schema XSD Indicators XSD Data Types XSD Schema References.
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.
Working with XML Schemas ©NIITeXtensible Markup Language/Lesson 3/Slide 1 of 36 Objectives In this lesson, you will learn to: * Declare attributes in an.
XML Schema (W3C) Thanks to Jussi Pohjolainen TAMK University of Applied Sciences.
XML Validation II Schemas Robin Burke ECT 360. Outline Namespaces Documents  Data types XML Schemas Elements Attributes Derived data types RELAX NG.
Introduction to XML Schema John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: (x2073)
When we create.rtf document apart from saving the actual info the tool saves additional info like start of a paragraph, bold, size of the font.. Etc. This.
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.
1 Internal DTD External DTD. 2 Internal DTD ]> Tove Jani Reminder Don't forget me this weekend.
Tutorial 2: XML Working with Namespaces. 2 Name Collision This figure shows two documents each with a Name element.
XML Validation II Advanced DTDs + Schemas Robin Burke ECT 360.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
Lecture 0 W3C XML Schema. Topics Status Motivation Simple type vs. complex type.
XML Schema – Simple Type Web site:
XML Schema – XSLT Week 8 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.
4 Copyright © 2004, Oracle. All rights reserved. Validating XML by Using XML Schema.
Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 1 of 28 Objectives In this lesson, you will.
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.
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
XML Data DTDs, IDs & IDREFs.
New Perspectives on XML
New Perspectives on XML
Presentation transcript:

XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended to be used as a tutorial on XML and related technologies Slide author: Jürgen Mangler This section contains examples on: XML Schema

The purpose of XML Schema is to deploy a standard mechanism to describe and evaluate the datatype of the content of an element. XML examples: 12 correct eT also correct The XML Parser can not distiguish the content of an Element. This is where XML Schema comes in: <name xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi=" Jürgen Mangler

If we use the attribute " noNamespaceSchemaLocation ", we tell the document that the schema belongs to an element from the null namespace. Valid document: <name xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi=" Jürgen Mangler correct_0.xsd:

If we use the attribute "schemaLocation", we tell the document that the schema belongs to an element from some particular namespace. In the schema definition, you have to use the "targetNamespace" attribute, which defines the element's namespace. Valid document: <f:anElement xsi:schemaLocation=" correct_0.xsd" xmlns:f=" xmlns:xsi=" This Element contains some cdata. correct_0.xsd: <xsd:schema targetNamespace=" xmlns:xsd="

If we want the root element to be named "AAA", from null namespace and containing text only. correct_0.xsd: Valid document: xxx yyy

If we want the root element to be named "AAA", from null namespace, containing text and an element "BBB", we will need to set the attribute "mixed" to "true" - to allow mixed content. xxx yyy ZZZ aaa

We want the root element to be named "AAA", from null namespace, containing one "BBB" and one "CCC" element. Their order is not important.

We want the root element to be named "AAA", from null namespace, containing a mixture of any number (even zero), of "BBB" and "CCC" elements. We need to use the 'trick' below - we use a "sequence" element with "minOccurs" attribute set to 0 and "maxOccurs" set to "unbounded". The attribute "minOccurs" of the "element" elements has to be 0 too. Give a valid document!

We want the root element to be named "AAA", from null namespace, containing a mixture of any number (even zero) of "BBB" and "CCC" elements. You need to use the trick below - use "sequence" element with "minOccurs" attribute set to 0 and "maxOccurs" set to "unbounded", and the attribute "minOccurs" of the "element" elements must be set to 0 too. 111 YYY ZZZ A valid solution!

We want the root element to be named "AAA", from null namespace, containing either "BBB" or "CCC" elements (but not both) - the "choice" element. Other valid solutions? aaa

In XML Schema, the datatype is referenced by the QName. The namespace must be mapped to the prefix. 25

Restricting simpleType is relatively easy. Here we will require the value of the element "root" to be integer and less than Valid? Use to force element > 0. You can also combine min/max in !

If we want the element "root" to be either a string "N/A" or a string "#REF!", we will use N/A Other solutions?

If we want the element "root" to be either an integer or a string "N/A", we will make a union from an "integer" type and "string" type.

Below we define a group of common attributes, which will be reused. The root element is named "root", it must contain the "aaa" element, and this element must have attributes "x" and "y". Give a valid document!

Below we define a group of common attributes, which will be reused. The root element is named "root", it must contain the "aaa" and "bbb" elements, and these elements must have attributes "x" and "y". Valid document from the previous Schema!

We want the "root" element to have an attribute "xyz", which contains a list of three integers. We will define a general list (element "list") of integers and then restrict it (element "restriction") to have a length (element "length") of exactly three items. Documents on next page …

Valid! Not valid! Why? Use the same method for lists in the content of elem. We want the "root" element to have an attribute "xyz", which contains a list of three integers. We will define a general list (element "list") of integers and then restrict it (element "restriction") to have a length (element "length") of exactly three items.

The element "A" has to contain a string which is exactly three characters long. We will define our custom type for the string named "myString" and will require the element "A" to be of that type. abc

The element "A" must contain an address. We will define our custom type, which will at least approximately check the validity of the address. We will use the "pattern" element, to restrict the string using regular expressions.

Regular Expressions - the meaning of: [abc]…Characters Class (character can be a, b or c) [^abc]…Negative Character Class (everything except a,b,c) *…Match 0 or more times +…Match 1 or more times ?…Match 1 or 0 times {n}…Match exactly n times {n,}…Match at least n times {n,m}…Match at least n but not more than m times.…match any character \w …Match a "word" character (alphanumeric plus "_") \W …Match a non-word character \d …Match a digit character \D …Match a non-digit character \.…Escape a character with a special Meaning (., +, *, ?, …) any character that is not 1 or more exactly [^.]+…match any character that is not a. 1 or more times \.…match exactly a..+…match any character 1 or more times

One of the big problems of XML ist the type ID. An attribute of type ID must be unique for the whole file. XML Schema solves this problem: ID's can be vaild for a certain child axis only. Document on next page …

One of the big problems of XML ist the type ID. An attribute of type ID must be unique for the whole file. XML Schema solves this problem: ID's can be vaild for a certain child axis only.

The "keyref" lets you specify, that an attribute/element refers to some node (which must be defined as "key" or "unique"). The "key" element requires the elements "a" under the "root" element to contain the existing and unique value of an "id" attribute. Replace with: Document on next page … Add to in myList:

The "keyref" lets you specify, that an attribute/element refers to some node (which must be defined as "key" or "unique"). The "key" element requires the elements "a" under the "root" element to contain the existing and unique value of an "id" attribute.

To define attributes AND childs for a certain element you have to use simpleContent. shake

simpleType: Wenn ich den Inhalt eines Elements als xsd:string, xsd:integer, xsd:double,... definieren will complexType Wenn ich Attribute definieren will Wenn ich andere Elemente als Inhalt definieren will (mit sequence, choice, all) Wenn ich Attribute und Elemente mischen will (xsd:attribute unterhalt von sequence, choice, all simpleContent innerhalb von complexType Wenn ich den Inhalt eines Elements als Datentyp definieren und zusätzlich Attribute haben will Wann nehm ich simple-, wann complexType