XML Schema. Schedule. Namespace. XML and DTD. Namespace: Example. XML Schema (www.w3.org/xml/schema) This week. Next week

Similar documents
XML Schema Definition Language (XSDL)

04 XML Schemas. Software Technology 2. MSc in Communication Sciences Program in Technologies for Human Communication Davide Eynard

Introduction to XML. Data Integration. Structure in Data Representation. Yanlei Diao UMass Amherst Nov 15, 2007

Last Week. XML (extensible Markup Language) HTML Deficiencies. XML Advantages. Syntax of XML DHTML. Applets. Modifying DOM Event bubbling

Geography Markup Language (GML) simple features profile

SW : : Introduction to Web Services with IBM Rational Application Developer V6

Schema Developer s Guide

OpenTravel Alliance XML Schema Design Best Practices

Introduction to Web Services

DTD Tutorial. About the tutorial. Tutorial

Quiz! Database Indexes. Index. Quiz! Disc and main memory. Quiz! How costly is this operation (naive solution)?

How To Write A Contract Versioning In Wsdl 2.2.2

XML and Data Management

XML: extensible Markup Language. Anabel Fraga

Java and XML parsing. EH2745 Lecture #8 Spring

Languages for Data Integration of Semi- Structured Data II XML Schema, Dom/SAX. Recuperación de Información 2007 Lecture 3.

Model-driven Rule-based Mediation in XML Data Exchange

Chapter 3: XML Namespaces

Using XML Schema Definitions with Adobe LiveCycle Designer 7.0

BACKGROUND. Namespace Declaration and Qualification

CHAPTER 9: DATAPORT AND XMLPORT CHANGES

Semistructured data and XML. Institutt for Informatikk INF Ahmet Soylu

Translating between XML and Relational Databases using XML Schema and Automed

Exercises: XSD, XPath Basi di da4 2

Structured vs. unstructured data. Semistructured data, XML, DTDs. Motivation for self-describing data

XML. Dott. Nicole NOVIELLI XML: extensible Markup Language

T Network Application Frameworks and XML Web Services and WSDL Tancred Lindholm

6. SQL/XML. 6.1 Introduction. 6.1 Introduction. 6.1 Introduction. 6.1 Introduction. XML Databases 6. SQL/XML. Creating XML documents from a database

Modernize your NonStop COBOL Applications with XML Thunder September 29, 2009 Mike Bonham, TIC Software John Russell, Canam Software

International Label APIs

XML Databases 6. SQL/XML

XML. Document Type Definitions XML Schema

Visualization of GML data using XSLT.

XML Schemadefinition

Spring,2015. Apache Hive BY NATIA MAMAIASHVILI, LASHA AMASHUKELI & ALEKO CHAKHVASHVILI SUPERVAIZOR: PROF. NODAR MOMTSELIDZE

DRAFT. Standard Definition. Extensible Event Stream. Christian W. Günther Fluxicon Process Laboratories

Extensible Markup Language (XML): Essentials for Climatologists

CST6445: Web Services Development with Java and XML Lesson 1 Introduction To Web Services Skilltop Technology Limited. All rights reserved.

Core Components Data Type Catalogue Version October 2011

Markup Languages and Semistructured Data - SS 02

Structured vs. unstructured data. Motivation for self describing data. Enter semistructured data. Databases are highly structured

The C Programming Language course syllabus associate level

XEP-0337: Event Logging over XMPP

No Trade Secrets. Microsoft does not claim any trade secret rights in this documentation.

Altova XMLSpy Tutorial

10CS73:Web Programming

Open Grid Services Infrastructure (OGSI) Version 1.0

Representation of E-documents in AIDA Project

XML Based Customizable Screen. Rev 1.1

The A2A Data Model and its application in WieWasWie. Michel

Using XBRL and Quantrix Modeler to Analyze Financial Statements Part 1

An XML Based Data Exchange Model for Power System Studies

Mobile Web Services: Architecture and Implementation

Designing the Service Contract

[MS-MDE]: Mobile Device Enrollment Protocol. Intellectual Property Rights Notice for Open Specifications Documentation

<Namespaces> Core XML Technologies. Why Namespaces? Namespaces - based on unique prefixes. Namespaces. </Person>

EHR-IIS Interoperability Enhancement Project. Transport Layer Protocol Recommendation Formal Specification. Version 1.

Developer Guide. Christian W. Günther Library version: 1.0 RC7 Revision: 7

Chapter 15 Working with Web Services

JAXB Tips and Tricks Part 2 Generating Java Classes from XML Schema. By Rob Ratcliff

Textual Modeling Languages

[MS-DVRD]: Device Registration Discovery Protocol. Intellectual Property Rights Notice for Open Specifications Documentation

How To Write A Technical Interoperability Standard For Spain

Integration and interoperability of data sources: forward into the new century

XES. Standard Definition. Where innovation starts. Den Dolech 2, 5612 AZ Eindhoven P.O. Box 513, 5600 MB Eindhoven The Netherlands

Connecting to WebSphere ESB and WebSphere Process Server

RTI Routing Service. Release Notes

Customer Information Quality Specifications Version 3.0 Name (xnl), Address (xal), Name and Address (xnal) and Party (xpil)

XML for Analysis Specification. Version 1.1 Microsoft Corporation Hyperion Solutions Corporation Updated: 11/20/2002

Web Services Technologies

Standardized Multimedia Retrieval in Distributed Heterogenous Database Systems. Dr. Mario Döller

Address Phone & Fax Internet

java.util.scanner Here are some of the many features of Scanner objects. Some Features of java.util.scanner

A Brief Introduction to MySQL

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

XIII. Service Oriented Computing. Laurea Triennale in Informatica Corso di Ingegneria del Software I A.A. 2006/2007 Andrea Polini

Developing a Web Service Based Application for Mobile Client

Chris Smith, Platform Computing Marvin Theimer, Microsoft Glenn Wasson, UVA July 14, 2006 Updated: October 2, 2006

Implementing XML Schema inside a Relational Database

HMIS XML Version 3.0 Cumulative Package Overview

XML for RPG Programmers: An Introduction

RUT developers handbook 9.51 Introduction to XML and DOM, with applications in Matlab v. 2.0

Transcription:

XML Schema Nan Niu (nn@cs.toronto.edu) CSC309 -- Fall 2008 This week Tuesday: lecture Schedule Thursday: A3 due (no tutorial) A4 will be posted around Thursday Next week Tuesday: no lecture Thursday: A2 re-marking & A4 office hour, in BA 5170 2 XML and DTD Learned on Oct 7 Well-formed vs. valid Deficiencies in DTDs Do not use XML syntax Do not support namespaces Data types cannot be strictly specified For example, date vs. string Web interoperability 3 Namespace Support modularity and reuse; avoid name collision Document may include elements and attributes from different schemas Namespaces are used to disambiguate Defined with xmlns attribute xmlns[:prefix]=url If no prefix is specified, it is referred to as the defaults namespace URI uniquely identifies namespace Has no further meaning 4 Namespace: Example <countries xmlns= http://www.countries-info.org/countries xmlns:cap= http://www.countries-info.org/countrycapitals > <country> <name> Mexico </name> <population>108,700,891 <population> <capital> <cap:name> Mexico </cap:name> <cap:population> 18,131,000 </cap:population> </capital> </country> <!--more countries--> XML Schema (www.w3.org/xml/schema) XML Schemas express shared vocabularies and allow machines to carry out rules made by people. They provide a means for defining the structure, content and semantics of XML documents. </countries> 5 6 1

Schema Description of an XML content model Define structure of instances Define data types of elements and attributes Is an XML application Follow XML syntax Support namespaces The XML Schema language itself is a set of XML tags The application being described is another set of XML tags Documents that conform to a schema s rules are considered instances of that schema 7 Sample Schema <xsd:schema xmlns= http://www.library.org xmlns:xsd= http://www.w3c.org/2001/xmlschema targetnamespace= http://www.library.org > <xsd:element name= Book > </xsd:element> <xsd:element name= Library > <xsd:complextype> <xsd:sequence> <xsd:element ref= Book minoccurs= 0 maxoccurs= unbounded /> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:schema> 8 Conceptual Model 9 XML Schema xmlns = http://www.w3.org/2001/xmlschema Tags <schema> <element> <attribute> Primitive and derived data types int, boolean, string, date, anyuri, etc. 10 XML Schema Definition (XSD) Document model that conforms to the XML Schema standard An XML application that can be used to describe other XML applications (document types) Defined in terms of the XML Schema tag set: <schema> <element> <attribute> <schema> Root element for schema documents xmlns For the schema namespace and for the namespace being defined xmlns:xsd= http://www.w3.org/2001/xmlschema targetnamespace Declare the namespace being defined elementformdefault With the value qualified, all elements defined in the target namespace must be namespace qualified when used, i.e., either with a prefix or be the default 11 12 2

<schema>: Example <schema xmlns= http://www.w3.org/2001/xmlschema xmlns:c= http://www.cs.toronto.edu/courses targetnamespace= http://www.cs.toronto.edu/courses elementformdefault= qualified > </schema> <schema>: Example (More Commonly Used) <xsd:schema xmlns= http://www.w3.org/2001/xmlschema xmlns:c= http://www.cs.toronto.edu/courses targetnamespace= http://www.cs.toronto.edu/courses elementformdefault= qualified > </xsd:schema> 13 14 <element> type ref Must reference a global element maxoccurs (nonnegativeinteger unbounded) : 1 minoccurs nonnegativeinteger : 1 (simpletype complextype) <element>: Example Definition <element name= score type= integer default= 0 /> Instances <score /> <score>124</score> Built-in types: boolean, integer, float, double, decimal, string, nonemptystring, time, date 15 16 <attribute> type default use (optional prohibited required) : optional ref Must reference a global element simpletype <attribute>: Example Create new attributes <attribute name= format type= string /> <attribute name= uri type= string use= required /> How to associate attributes to elements? 17 18 3

Element with Attributes Definition <element name= picture > <attribute name= format type= string use= optional /> <attribute name= uri type= string use= required /> Instance <picture format= GIF uri= images/blue_jays.gif /> 19 4 kinds of complex elements Empty elements <product pid= 123 /> Elements that contain only other elements <employee> <firstname>john</firstname> <lastname>green</lastname> </employee> Elements that contain only text <food type= dessert >Ice cream</food> Elements that contain both other elements and text <description> It happened on <date lang= norwegian >03.03.99</date> </description> Each of the above elements may contain attributes as well 20 (all choice sequence group ) all: each child appears (at most) once in any order <xsd:all> <xsd:element name= firstname /> <xsd:element name= lastname /> choice: only one of its children is allowed <xsd:choice> <xsd:element name= prof /> <xsd:element name= student /> sequence: in the given order <xsd:squence> <xsd:element name= firstname /> <xsd:element name= lastname /> group: a custom defined group attribute 21 Example of Nested Element 22 Example of Repeatable Elements (restriction list union) restriction: constrain the range of values list: list of the defined type union: union of the included types 23 24 4

Constraining Facets (<restriction>) length maxinclusive minlength maxexclusive maxlength minexclusive pattern maxinclusive enumeration totaldigits whitespace fractiondigits 25 Example <simpletype name= testu > <restriction base= string > <pattern value= \d{3}-{a-z}{2} /> </restricion> Pattern matches Three digits followed by a hyphen followed by two upper-case ASCII letters XML Schema Regular Expression References http://www.xmlschemareference.com/regularexpress ion.html http://www.w3.org/tr/xmlschema-2/#dt-regex 26 Constraining Element Content and Attribute Value Constraining Element Content and Attribute Value New simpletype References an existing type through base attribute Restricts or extends existing type Example 1: <attribute name= Security > <restriction base= NMTOKEN > <enumeration value= normal /> <enumeration value= secret /> <enumeration value= topsecret /> </restriction> </attribute> Example 2 <simpletype name= internalemailaddress > <restriction base= anyuri > <pattern value= [a-za-z]+\.[a-za-z]+@cs.toronto.edu /> </restrintion> <element name= studentemail type= internalemailaddress /> 27 Example 3: <element name= stockprice > <restriction base= decimal > <totaldigits value= 5 /> <fractiondigits value= 2 /> <mininclusive value= 0 /> </restriction> Example 4: Extension based on Unions <simpletype name= timeordate > <union membertypes= time date /> 28 Named Complex Types A complextype that is named in the schema can be set as the type of an element Option 1 <element name= Email > <sequence> <element ref= E:From />.. </sequence> Option 2 <complextype name= emailtype > <sequence> <element ref= E:From />.. </sequence> <element name= Email type= E:eMailType > Schema Processor / Validator Validates a document instance against a schema definition Online validation http://www.w3.org/2001/03/webdata/xsv Apache Xerces Java parser http://xml.apache.org/xerces-j/schema.html java Validator v library.xml http://xerces.apache.org/xerces2-j/ java -cp xercesimpl.jar;. Validator -v library.xml 29 30 5