XML Schema (W3C) Thanks to Jussi Pohjolainen TAMK University of Applied Sciences.

Slides:



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

1 Web Data Management XML Schema. 2 In this lecture XML Schemas Elements v. Types Regular expressions Expressive power Resources W3C Draft:
 Fundamentals of Web Design.  Describe the history and theory of XHTML  Understand the rules for creating valid XHTML documents  Apply a DTD to an.
An Introduction to XML Based on the W3C XML Recommendations.
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.
A Simple Schema Design. First Schema Design Being a Dog Is a Full-Time Job Charles M. Schulz Snoopy Peppermint Patty extroverted beagle Peppermint.
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.
Tutorial 9 Working with XHTML. XP Objectives Describe the history and theory of XHTML Understand the rules for creating valid XHTML documents Apply a.
DECO 3002 Advanced Technology Integrated Design Computing Studio Tutorial 6 – XML Schema School of Architecture, Design Science and Planning Faculty of.
1 Week5 – Schema Why Schema? Schemas vs. DTDs Introduction – W3C vs. Microsoft XDR Schema, How To? Element Types – Simple vs. Complex Attributes Restrictions/Facets.
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
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
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.
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.
XP The University of Akron Summit College Business Technology Department Computer Information Systems 2440: 140 Internet Tools Instructor: Enoch E. Damson.
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.
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.
E X TENSIBLE M ARKUP L ANGUAGE (XML). What is XML?  XML stands for EXtensible Markup Language  XML is mainly designed to carry (or transmit) data, not.
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.
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
CSE4500 Information Retrieval Systems XML Schema – Part 1.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Schemas Ellen Pearlman Eileen Mullin Programming the Web Using XML.
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.
 2002 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 – Schemas Outline 7.1Introduction 7.2Schemas vs. DTDs 7.3Microsoft XML Schema: Describing Elements.
Introduction to XML. What is XML? Extensible Markup Language XML Easier-to-use subset of SGML (Standard Generalized Markup Language) XML is a.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
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 –
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.
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.
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.
Introduction to XML Schema John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: (x2073)
1 Compound Documents: Combining XML Vocabularies.
XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
Tutorial 2: XML Working with Namespaces. 2 Name Collision This figure shows two documents each with a Name element.
Introduction to XML Namespaces Web Engineering, SS 2007 Tomáš Pitner.
Tutorial 9 Working with XHTML. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Describe the history and theory of XHTML.
Introduction to XML Jussi Pohjolainen TAMK University of Applied Sciences.
CIS 228 The Internet 9/20/11 XHTML 1.0. “Quirks” Mode Today, all browsers support standards Compliant pages are displayed similarly There are multiple.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
Tutorial 9 Working with XHTML. XP Objectives Describe the history and theory of XHTML Understand the rules for creating valid XHTML documents Apply a.
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 14 This presentation © 2004, MacAvon Media Productions XML.
XML Namespaces In this first lesson XML Namespaces, you will learn to:
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
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.
XML SCHEMA 1 CH 20. Objective 2 What’s wrong with DTDs? What is a schema? The W3C XML Schema Language Hello schemas Complex types Simple types Deriving.
4 Copyright © 2004, Oracle. All rights reserved. Validating XML by Using XML Schema.
MSc in Communication Sciences Program in Technologies for Human Communication Davide Eynard Facoltà di scienze della comunicazione Università.
Extensible Markup Language (XML) Pat Morin COMP 2405.
XML Schemas Dr. Awad Khalil Computer Science Department AUC.
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Presentation transcript:

XML Schema (W3C) Thanks to Jussi Pohjolainen TAMK University of Applied Sciences

XML NAMESPACES w3schools.com

XML Namespaces The idea behing XML namespaces is to avoid element name conflicts. Example of name conflict (w3schools.com) Apples Bananas African Coffee Table Same tag-name, different content and meaning!

Solving Name Conflict Apples Bananas African Coffee Table Prefix h has xhtml-related elements and prefix f has furniture-related elements

xmlns - attributes When using prefixes in XML, a so-called namespace for the prefix must be defined. The namespace is defined by the xmlns attribute in the start tag of an element.

xmlns - attribute Apples Bananas African Coffee Table

xmlns - attribute <root xmlns:h=" xmlns:f=" Apples Bananas African Coffee Table

Namespace name The name of namespace should be unique: It is just a string, but it should be declared as URI. Using URI reduces the possibility of different namespaces using duplicate identifiers.

Example: An XHTML + MathML + SVG Profile An XHTML+MathML+SVG profile is a profile that combines XHTML 1.1, MathML 2.0 and SVG 1.1 together. This profile enables mixing XHTML, MathML and SVG in the same document using XML namespaces mechanism.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" " <html xmlns = " xmlns:svg = " Example of XHTML, SVG and MathML MathML a b SVG

W3C SCHEMA

XML Schema (W3C) Language for defining set of rules for XML – documents. W3C Recommendation (2001) More specific than DTD – Datatypes! Is XML-language and it uses xml namespaces

Schema vs. DTD (W3Schools.com) XML Schemas are extensible to future additions XML Schemas are richer and more powerful than DTDs XML Schemas are written in XML XML Schemas support data types XML Schemas support namespaces

DTD Linking Defines the structure, tag names and order for all xhtml - documents W3C has created XML-language "XHTML" by defining it's rules in DTD. W3C has created XML-language "XHTML" by defining it's rules in DTD.

DTD Linking Defines the structure, tag names and order for all "book"- documents TAMK has created XML-language "Book" by defining it's rules in DTD. TAMK has created XML-language "Book" by defining it's rules in DTD.

Schema Linking Defines the structure, tag names and order for all "book"- documents TAMK has created XML-language "Book" by defining it's rules in a Schema. TAMK has created XML-language "Book" by defining it's rules in a Schema.

Linking? The basic idea with linking to Schema:... The problem with this is that now it is set that attribute "schemaLocation" is part of your XML-language

Linking and Namespace Usage Linking with namespace <root xmlns:xsi=" xsi:schemaLocation="note.xsd">... Now the "schemaLocation" – attribute is in it's own namespaces (xsi) and does not belong to the "main" language.

Simple Schema

Let's remove namespaces... It doesn't look so confusing after all? It doesn't look so confusing after all?

The Basics: Element You define the name for the elements by using element -element. – Type? – 44 Built-in schema datatypes – string, double, time, date, etc. – See all the datatypes See all the datatypes

Usage of Datatypes <xsd:element name="firstname" type="xsd:string" /> <xsd:element name="ableToSwim" type="xsd:boolean" /> <xsd:element name="date" type="xsd:date" />

minOccurs and maxOccurs The amount of elements – In DTD: *, ?, + – In Schema: minOccurs, maxOccurs Example Default and special values – default minOccurs : 1 – default maxOccurs : same as minOccurs –maxOccurs="unbounded" : unlimited

Defining new Datatypes If the the built-in datatypes are not enough, you can build your own datatypes. This does not necessarily work: – There are two ways of specifying your own datatype – Named Data Type – Anonymous Data Type

1) Named Data Type

2) Anonymous Data Type

Benefits of Named Data Type If you want re-use your datatype:

SimpleType: enumeration Alternative content

SimpleType: pattern Using REGEX:

REGEX Examples

Structure of the XML-file It's possible to define the structure of the XML-file using complexType If element A has child-elements, then element A's type is complexType

SimpleType vs. ComplexType SimpleType – 7 – Since grade does not hold other child – elements, grade's type is simpleType ComplexType – Jack – Since student does hold child – element(s), student's type is complexType

Example: XML - File Pekka Virtanen

Example: XSD – file Named ComplexType Use now complexType (vs. simpleType)

Example: XSD – file Anonymous ComplexType

Example: ComplexType

Deep Structure in XML - File Pekka

Using Anonymous Data Type: The Horror!

"There is an error in my schema, could you find it for me?"

Use Named Datatypes! It's easier to find errors..

Order of the elements Sequence: Elements appear in same order than in Schema All: Elements can appear in any order Choice: One element can appear from the choice-list

Attribute XML –... Schema...

Empty Element with Attribute XML – Schema

PHP5 and Schema With PHP5 you do not have to link xml to schema – files. – The linking is done in PHP5 – code, not in XML. Example of schema-validation: $doc = new domDocument; if ( $doc->load("books.xml") and $doc->schemaValidate("books.xsd') ) { print "Is WellFormed and Schema-valid!"; }