Creating Extensible Content Models XML Schemas: Best Practices A set of guidelines for designing XML Schemas Created by discussions on xml-dev.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

CSPP51038 WSDL in depth. Advanced Schema features (required for understanding wsdl)
What is XML? a meta language that allows you to create and format your own document markups a method for putting structured data into a text file; these.
1 Web Data Management XML Schema. 2 In this lecture XML Schemas Elements v. Types Regular expressions Expressive power Resources W3C Draft:
Copyright © Open Applications Group, Inc. All rights reserved 1 OAGi XML Schema User Report June 21, Michael.
+ XSL eXtensible Stylesheet Language. + 2 XML Lecture Adapted from the work of Prof Mark Baker ACET, University of Reading.
Achieving Distributed Extensibility and Versioning in XML Dave Orchard W3C Lead BEA Systems.
1 Implementing Variable Content Containers XML Schemas: Best Practices A set of guidelines for designing XML Schemas Created by discussions on xml-dev.
XML Schemas Microsoft XML Schemas W3C XML Schemas.
IS 373—Web Standards Todd Will
XML Schemas Lecture 10, 07/10/02. Acknowledgements A great portion of this presentation has been borrowed from Roger Costello’s excellent presentation.
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents Roger L. Costello XML Technologies.
1 Substitution Groups in XML Schemas Tomer Shiran Winter 2003/4 Semester.
DECO 3002 Advanced Technology Integrated Design Computing Studio Tutorial 6 – XML Schema School of Architecture, Design Science and Planning Faculty of.
XML Schemas and Namespaces Lecture 11, 07/10/02. BookStore.dtd.
ΑΝΑΠΑΡΑΣΤΑΣΗ ΓΝΩΣΗΣ ΣΤΟΝ ΠΑΓΚΟΣΜΙΟ ΙΣΤΟ XML Schema
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
Copyright (c) [2001]. Roger L. Costello. All Rights Reserved. 1 … more on XML Schemas Roger L. Costello XML Technologies Course.
1 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Using Extension Elements and Extension Functions with XSLT and XPath Roger L. Costello.
1 HTML’s Transition to XHTML. 2 XHTML is the next evolution of HTML Extensible HTML eXtensible based on XML (extensible markup language) XML like HTML.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
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.
Using XSLT and XPath to Enhance HTML Documents Reference: Roger L. Costello
ECA 228 Internet/Intranet Design I Intro to XML. ECA 228 Internet/Intranet Design I HTML markup language very loose standards browsers adjust for non-standard.
Main challenges in XML/Relational mapping Juha Sallinen Hannes Tolvanen.
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
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
Lecture Roger Sutton CO530 Automation Tools 5: Class Libraries and Assemblies 1.
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
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
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.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
Extending XML Schemas XML Schemas: Best Practices A set of guidelines for designing XML Schemas Created by discussions on xml-dev.
Default Namespace - targetNamespace or XMLSchema? XML Schemas: Best Practices A set of guidelines for designing XML Schemas Created by discussions on xml-dev.
XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard.
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 –
New Perspectives on XML, 2nd Edition
XML Documents Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University Elements Attributes Comments PI Document.
Web Architecture: Extensible Language Tim Berners-Lee, Dan Connolly World Wide Web Consortium 元智資工所 系統實驗室 楊錫謦 1999/9/15.
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.
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
Introduction to XML February 07, From HTML to XML As mentioned in previous classes, if you know HTML, then you already know XML… really! In this.
Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka.
INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
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.
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents Roger L. Costello XML Technologies.
Abierman-sming-nov02 1 SMIv3 Open Issues Andy Bierman.
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.
Deriving Complex Types In XML Schema By: Roy Navon.
Tutorial 2: XML Working with Namespaces. 2 Name Collision This figure shows two documents each with a Name element.
XML Schema Lecture 3. Indicators There are seven indicators: Order indicators: All Choice Sequence Occurrence indicators: maxOccurs minOccurs Group indicators:
1 Global versus Local XML Schemas: Best Practices A set of guidelines for designing XML Schemas Created by discussions on xml-dev.
XML CORE CSC1310 Fall XML DOCUMENT XML document XML document is a convenient way for parsers to archive data. In other words, it is a way to describe.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Web Services: Principles & Technology Slide 3.1 Chapter 3 Brief Overview of XML COMP 4302/6302.
CH 9 Attribute Declaration 1. Objective What is an attribute Declaring attributes Declaring multiple attribute Alternatives to default attributes values.
XML QUESTIONS AND ANSWERS
Eugenia Fernandez IUPUI
New Perspectives on XML
Presentation transcript:

Creating Extensible Content Models XML Schemas: Best Practices A set of guidelines for designing XML Schemas Created by discussions on xml-dev

Definition An element has an extensible content model if in instance documents that element can contain elements and data above and beyond what was specified by the schema.

Static, Fixed Content Model The First and Last Freedom J. Krishnamurti Harper & Row Book is rigidly defined to contain five child elements - Title, Author, Date, ISBN, and Publisher. Instance document authors are restricted to just supplying title, author, date, ISBN, and publisher data for a book. Book's content model is static/fixed!

Static, Fixed Content Model Sometimes it is desirable to explicitly specify an element's content model. Sometimes, however, we want to give instance document authors more flexibility in what data they can provide for an element. How do we design a schema such that Book's content model is extensible? We will look at two methods for implementing extensible content models.

Extensibility via Type Substitution

-- content -- Principle of Type Substitutability The content model of Book can be either BookType, or any type which derives from BookType, e.g., BookTypePlusReviewer Extensibility via Type Substitution

The First and Last Freedom J. Krishnamurti Harper & Row Roger L. Costello The type substitutability mechanism enables instance document authors to extend Book's content model by substituting its type with a derived type. Here we see that BookType has been substituted by the type: BookTypePlusReviewer. Thus, now contains a new element,. Extensibility via Type Substitution Do Lab1

Extend a Schema, without Touching it! In the last example BookTypePlusReviewer derived from BookType, and both types were in the same schema. What if we need to extend BookType, but BookCatalogue.xsd is read-only? In a separate schema, we can create a type which extends BookType. The instance document can do type substitution using the new type. Thus, we are able to extend a schema, without touching it!

Extend a Schema, without Touching it! BookCatalogue.xsd xmlns=" MyTypeDefinitions.xsd

Extend a Schema, without Touching it! The First and Last Freedom J. Krishnamurti Harper & Row Roger L. Costello xsi:schemaLocation=" MyTypeDefinitions.xsd" xmlns=" We have type-substituted Book's content with the type specified in the new schema. Thus, we have extended BookCatalogue.xsd without touching it!

Disadvantages of using Type Substitution for Extending an Element's Content Model Location Restricted Extensibility: –The extensibility is restricted to appending elements onto the end of the content model (after the element). What if we wanted to extend by adding elements to the beginning (before ), or in the middle, etc? We can't do it with this mechanism.

Disadvantages of using Type Substitution for Extending an Element's Content Model Unexpected Extensibility: Simply looking at these components you would think that will always contain just Title, Author, Date, ISBN, and Publisher. It is easy to forget that someone could extend the content model using the type substitution mechanism. Extensibility is unexpected! Consequently, if you create a program to process Book's content you may forget to take into account that Book may contain different content.

Here's what we Desire for Extending Content Models Location Independent Extensibility: –We would like to be able to extend Book's content at any location, not just at the end. For example, we might wish to add elements at the top (before Author), or in the middle (after Date), etc. Explicit Indication of where Extensibility may Occur: –It would be nice if there was a way to explicitly flag places where extensibility may occur: "hey, instance documents may extend at this point, so be sure to write your code taking this possibility into account."

Extensibility via the Element "The content of Book is Title, Author, Date, ISBN, Publisher and then (optionally) any well-formed element. The new element may come from any namespace." Note: the element may be inserted at any point, e.g, it could be inserted at the top, in the middle, etc.

Extensibility via the Element xmlns=" MyRepository.xsd xmlns=" BookCatalogue.xsd In an instance document I can insert this Reviewer element after Publisher.

The First and Last Freedom J. Krishnamurti Harper & Row Roger Costello xsi:schemaLocation=" BookCatalogue.xsd MyRepository.xsd" xmlns=" xmlns:rev=" This instance document author has extended Book with an element that the schema designer may have never even envisioned. We have empowered the author to create instance documents which contains all the data he/she requires.

Alternate Schema for Book This is a better design than the previous version since now we have a nice reusable BookType component. However, we are back to the "unexpected extensibility" problem. Consequently, after the Publisher element there may be any well-formed XML element, and after that anything could be present (due to type substitutability).

Controlling Extensibility using the block Attribute We can add a block attribute to the element declaration to prohibit type substitution:

Control over where and how much Extensibility We can put the element specifically where we desire extensibility. If we desire extensibility at multiple locations, we can insert multiple elements. With maxOccurs we can specify "how much" extensibility we will allow. - We are restricting extensions to occur at the top of the content model. - We are restricting the amount of extensibility to two elements.

Recognizing our Limitations The element allows a schema designer to recognize that he/she is not able to anticipate all the varieties of data that an instance document author might need to use in creating an instance document: "I'm smart enough to know that I'm not smart enough to anticipate all possible needs!" Do Lab 2

Non-determinism and the element My Life and Times... Schema: Instance: Does this element correspond to the element, or the Title element declaration? Impossible to determine without "looking ahead" to the next element. The Book element has a non-deterministic content model. Non-determinism content models are illegal.

Definition of Non-determinism Defn: A non-deterministic content model is one where, upon encountering an element in an instance document, it is ambiguous which path was taken in the schema document.

Non-determinism and the element My Life and Times... Schema: Instance: Clearly this element must have come from the Title element declaration, because the element requires new elements to come from a namespace other than the targetNamespace. Thus, this schema has a deterministic content model and is legal.

Non-determinism and the element My Life and Times... Schema: Instance: Does this Title element come from the element, or from the Title element being ref'ed? There is no way of knowing, without looking ahead. Thus, this is non-deterministic, and illegal. Suppose that the Book element is comprised of components from a variety of namespaces.

--> Quite Restricted As we have seen, the requirement that all elements have deterministic content models imposes serious restrictions on the use of the element. So, what do you do when you want to enable extensibility at arbitrary locations? Answer: embed the element within an element.

My Life and Times... Schema: Instance: Now we are forcing any additional elements to be embedded within an optional element. No more ambiguity about where this Title element comes from, i.e., no more non-determinism! Embed Additional Elements within an Element

Commentary Requiring instance document authors to nest additional element within an element is poor, at best. The whole reason that this design pattern was forced upon us is due to XML Schemas rule outlawing non- deterministic content models. –They did this to simplify implementations of Schema validators. Write to the XML Schema Working Group requesting that they remove the rule outlawing non-deterministic content models.