Enabling Grids for E-sciencE www.eu-egee.org ISSGC’05 XML Schemas (XSD) Richard Hopkins, National e-Science Centre, Edinburgh June 2005.

Slides:



Advertisements
Similar presentations
On and use=document|rpc, style=literal|encoded A personal opinion Sanjiva Weerawarana IBM Research September 9-11, 2002.
Advertisements

XML Schema Heewon Lee. Contents 1. Introduction 2. Concepts 3. Example 4. Conclusion.
CSPP51038 WSDL in depth. Advanced Schema features (required for understanding wsdl)
BT User Experiences Jon Calladine 21st June 2005.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
CIS 375—Web App Dev II SOAP.
1 Web Data Management XML Schema. 2 In this lecture XML Schemas Elements v. Types Regular expressions Expressive power Resources W3C Draft:
An Introduction to XML Based on the W3C XML Recommendations.
Copyright © Open Applications Group, Inc. All rights reserved 1 OAGi XML Schema User Report June 21, Michael.
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.
Enabling Grids for E-sciencE ISSGC’05 XML documents Richard Hopkins, National e-Science Centre, Edinburgh June 2005.
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
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.
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.
Enabling Grids for E-sciencE Schemas Richard Hopkins National e-Science Centre, Edinburgh February 23 /
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.
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.
1 XML Schemas. 2 Useful Links Schema tutorial links:
Dr. Azeddine Chikh IS446: Internet Software Development.
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 and friends Part 2 - XML Schema ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation.
Session IV Chapter 9 – XML Schemas
IVOA Registry videocon 2004/05/13-14 Gerard Lemson1 Model based schema.
Enabling Grids for E-sciencE PPARC Summer School, May 2005 Schemas (and XML) Richard Hopkins, National e-Science Centre, Edinburgh.
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.
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
XML Schema. Why Validate XML? XML documents can generally have any structure XML grammars define specific document structures Validation is the act of.
Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka.
EGEE is a project funded by the European Union under contract IST XML Schema 3 – 4 June
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.
Introduction to XML Schema John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: (x2073)
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.
XML Schema Lecture 3. Indicators There are seven indicators: Order indicators: All Choice Sequence Occurrence indicators: maxOccurs minOccurs Group indicators:
Lecture 0 W3C XML Schema. Topics Status Motivation Simple type vs. complex type.
Experience with XML Schema Ashok Malhotra Schema Usage  Mapping XML Schema and XML documents controlled by the Schema to object classes and instances.
1 G52IWS: Web Services Description Language (WSDL) Chris Greenhalgh
Using XML Schema to define NETCONF Content Sharon Chisholm Alex Clemm TJ Tjong
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.
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.
XML Schemas Dr. Awad Khalil Computer Science Department AUC.
CMP 051 XML Introduction Session IV
Schemas Richard Hopkins National e-Science Centre, Edinburgh
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Discussion on XSD open issues
ISSGC’05 XML Schemas (XSD)
CMP 051 XML Introduction Session III
New Perspectives on XML
Presentation transcript:

Enabling Grids for E-sciencE ISSGC’05 XML Schemas (XSD) Richard Hopkins, National e-Science Centre, Edinburgh June 2005

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 2 Overview Goals – –General appreciation of XML and Schemas –Sufficient detail to understand WSDLs Structure –Schemas (XSD)  General  Elements, types and attributes  Inter-schema structures  Reality check

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 3 Introduction to SCHEMAS A Schema defines the syntax for an XML language –An XML document can have an associated Schema –It is valid if it meets the syntax rules of that schema –This can import syntax for (parts of) other languages Much like programming language type declarations, But some peculiarities –Has declaration of attributes - needed to define XML documents –Three ways to define the “type” of a value  Giving the sub-structure directly – anonymous type  Referring to a Type definition  Referring to an Element definition –Allows extension points –Quite a complex structure –  Is itself an XML document  Easier to read than to write –Example – Purchase Order document –

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 4 Validation / Generation Schema is a type – –defines a range of possible instances –The set of all instances which are “validated by the schema” “instance is validated by the schema” – it satisfies the schema definition Alternative terminology – –“schema matches the instance” –“instance matches the schema” …. …. Schema – XML documentInstance – XML document Validates Is Validated By Matches

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 5 ELEMENTS etc. Structure –Schemas (XSD)  General  Elements, types and attributes  Inter-schema structures  Reality check

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 6 Main Structure 10/24/04 Z135-ACE … 7-day … …. … <xs:schema …. xmlns:xs=" …. … … …. <xs:element ref="note" minOccurs="0" maxOccurs="3"/> <xs:element name="entry" type="entryT" maxOccurs="unbounded"/> … 1. schema “envelope” - “xs” = schema namespace. Or “xsd” 2. PO - global complex element - a sequence of child elements - Date, accno, customer, note, Entry. An anonymous type 3. Date – see later 4. AccNo – element of global type 5. customer info – Nested complex element 6. note – reference to a global element – same name and type Repeated 0 – 3 times 7. entry – element of global type Repeated 1 or more times

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 7 PRINT VISIBLE COMMENTS OF PREVIOUS SLIDE 1. schema “envelope” - “xs” = schema namespace. Or “xsd” 2. PO - global complex element - a sequence of child elements - Date, accno, customer, note, Entry. An anonymous type 3. Date – see later 4. AccNo – element of global type 5. customer info – Nested complex element 6. note – reference to a global element – same name and type Repeated 0 – 3 times 7. entry – element of global type Repeated 1 or more times

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 8 Global Items Annotations – Documentation (also appinfo) Can also go deeper in to annotate parts of structures … Here is a Schema … Order of global items is not significant Global (named) Types – Simple or complex – Use in giving type of element Elements - two roles The instance document can have an instance of this as its root element –PO or Note – not what’s intended ! Can be referenced from elsewhere as another way of giving “type” –  but must use same name Other things e.g. attributes, groups

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 9 Features of Complex Elements Nillable – can match element with attribute xsi:nil = “true”, and no content Occurrences – minOccurs, maxOccurs. Default is max can be “unbounded” –This schema item can match N occurrences of the element, Min<=N<=Max Model (feature of type)– –Sequence – each component matched in this order  But each component may actually match no elements or multiple elements  If there are any notes – after customer and before first entry 10/24/04 Z135-ACE …. … … <xs:element name="customer“ nillable=“1”> …. <xs:element ref="note" minOccurs="0" maxOccurs="3"/> <xs:element name="entry" type="entryT" maxOccurs="unbounded"/>

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 10 Complex Types – Models Model – –Sequence – each component matched in this order –Choice – one and only one component is matched  But each component may actually match no elements or multiple elements –All – each component matched in any order  Each component must match one or zero elements – maxOccurs=“1” … 10/24/04 … 24/10/04 …

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 11 Complex Elements – Models Model – –Sequence – each component matched in this order –Choice – one and only one component is matched  But each component may actually match no elements or multiple elements –All – each component matched in any order – use for “Struct”  Each component must match one or zero elements – maxOccurs=“1” … … … … … … … … …

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 12 Complex Types - Extension XentryT inherits the components of entryT - extend the sequence … …. … …. … …. … caretaker very

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 13 Complex Types - Extension Extension which adds no content – used to denote a special case … ….

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 14 Simple Elements/Types … optional restrictions …. …. <xs:element name="accNo“ type="accNoT"/> …. <xs:element ref="note" minOccurs="0" maxOccurs="3"/> …. … optional restrictions …. …. Z135-ACE … to collect ….. Element features Occurrences (local element) Default / Fixed values Nillable Type features Derivation as Restriction Base simple type ultimately a primitive xsd:type Restrictions patterns, enumerations, … Derivation as Union Derivation as List

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 15 Attributes Can associate attributes with a type –By in-line definition –By naming a globally declared attribute - see later Attribute has features – –Some simple type –Default/fixed –Use – optional (default), prohibited, required If it has an attribute, it must be a complex type –For a naturally complex type, just add it in at the first level –For an actually simple type - … … <xs:attribute name="collect" type="xs:boolean" use="optional" default="false"/> … ….

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 16 Adding attributes to simple types Has attribute - is complex type But it is simple content Extends a simple type with an attribute - could be several …… … … …

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 17 INTER-SCHEMA STRUCTURES Structure –Schemas (XSD)  General  Elements, types and attributes  Inter-schema structures  Reality check

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 18 Target Namespace The name of the language for which this schema defines the syntax This schema will only match an instance if its namespace matches - <xs:schema … targetNameSpace= “ … … If schema has no targetNameSpace – it can only match un-qualified names

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 19 Include All must be same target namespace Forms one logical schema as the combination of physically distinct schemas I.e. referencing main as the schema allows document to be an PO or an SE (stock enquiry) Allows individual document definitions to share type definitions <schema targetNameSpace= “…www. …/forms/ns”> <include schemaLocation= “…www…/Forms/Types.xsd"/> …. …www… /Forms/PO.xsd <schema targetNameSpace= “…www. …/forms/ns”> <simpleType name= “AccNoT“> …. ….other types …. …www… /Forms/Types.xsd <schema targetNameSpace= “…www. …/forms/ns”> <include schemaLocation= “…www…/Forms/Types.xsd"/> …. …www… /Forms/Inv.xsd <schema targetNameSpace= “…www. …/forms/ns”> <include schemaLocation= “…www…/Forms/PO.xsd"/> <include schemaLocation= “…www…/Forms/Inv.xsd"/> …www… /Forms/main.xsd

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 20 Import Include is to distribute the definition of this namespace (language) over multiple Schema definitions Import is to allow use of other namespaces (languages) in the definition for this language. <schema targetNameSpace= “…www. …/Standards/ns” > <simpleType name= “USdateT“> …. ….other types …. …www… /Standards.xsd <schema targetNameSpace= “…www. …/forms/ns” xmlns:st =“…www…/Standards/ns” > <import namespace= “…www…/Standards/ns” schemaLocation= “…www… /Standards.xsd” > …. … …www… /Forms/PO.xsd Must have namespace definition for import’s namespace

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 21 Extension points Web Services needs to accommodate extensibility –A PO can be “extended” with client’s own information about an order item – e.g. how the user allocates the cost -This is just reflected back in the Invoice –This element will be from the client’s namespace – unknown when writing the schema –Covered by an Any element (“wildcard”) –The Any element can define the allowed namespaces Extensibility covers two kinds of language enhancement –  Specialisation – namespace=“##other” anything but this names space – could view user-PO as a specialisation of PO  Versioning – namespace=“##local” this namespace … <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/> … …... …. …

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 22 REALITY CHECK Structure –XML  Philosophy  Detailed XML Format  Namespaces –Schemas (XSD)  General  Elements, types and attributes  Inter-schema structures  Reality check

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 23 Schema Generality Schemas are a moderately sophisticated type language –choice; all; any –union; pattern; … More sophisticated than e.g. Java type language Usage of the Schema generality depends on inter-operability issues Low interoperability –A configuration table for your particular application –Schema only for human consumption  User does not write programs that use the table –Could use full generality of schema definition language High Interoperability –WSDL for your web service –Schema used to define the structure of SOAP messages –Schema must be usable by any web services toolkit –Type structure must be translatable into any programming language type scheme –Lowest common denominator – WS-I

Enabling Grids for E-sciencE ISSGC’05 – June 2005 Schemas 24 Schemas within WSDLs Complex Elements –Sequence for distinctly-named component fields –Standard type for Array Simple Elements –A collection of standard types Excludes Any Extensions Choice All Repitition / optionality (maxoccurrs, minoccurrs) Mixed content …..