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

Slides:



Advertisements
Similar presentations
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.
Advertisements

XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
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.
XML 6.3 DTD 6. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:  Elements.
XML Document Type Definitions ( DTD ). 1.Introduction to DTD An XML document may have an optional DTD, which defines the document’s grammar. Since the.
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.
Document Type Definitions
XML Schemas Microsoft XML Schemas W3C XML Schemas.
Introduction to XLink Transparency No. 1 XML Information Set W3C Recommendation 24 October 2001 (1stEdition) 4 February 2004 (2ndEdition) Cheng-Chia Chen.
 2002 Prentice Hall, Inc. All rights reserved. ISQA 407 XML/WML Winter 2002 Dr. Sergio Davalos.
XML Schemas and Namespaces Lecture 11, 07/10/02. BookStore.dtd.
Full declaration When an element is declared to have element content, the children element types must also be declared Example: to which the following.
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:
XML Verification Well-formed XML document  conforms to basic XML syntax  contains only built-in character entities Validated XML document  conforms.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
Unit 4 – XML Schema XML - Level I Basic.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
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
Validating DOCUMENTS with DTDs
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.
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.
Neminath Simmachandran
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
XML Syntax - Writing XML and Designing DTD's
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.
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.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
 2002 Prentice Hall, Inc. All rights reserved. Chapter 6 – Document Type Definition (DTD) Outline 6.1Introduction 6.2Parsers, Well-formed and Valid XML.
Lecture 6 XML DTD Content of.xml fileContent of.dtd file.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
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 Extensible Markup Language Aleksandar Bogdanovski Programing Enviroment LABoratory
New Perspectives on XML, 2nd Edition
IS432 Semi-Structured Data Lecture 2: DTD Dr. Gamal Al-Shorbagy.
1/11 ITApplications XML Module Session 3: Document Type Definition (DTD) Part 1.
The eXtensible Markup Language (XML). Presentation Outline Part 1: The basics of creating an XML document Part 2: Developing constraints for a well formed.
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,
CSE3201 Information Retrieval Systems DTD Document Type Definition.
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
SNU OOPSLA Lab. Logical structure © copyright 2001 SNU OOPSLA Lab.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
1 Internal DTD External DTD. 2 Internal DTD ]> Tove Jani Reminder Don't forget me this weekend.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
Copyrighted material John Tullis 3/18/2016 page 1 04/29/00 XML Part 4 John Tullis DePaul Instructor
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 14 This presentation © 2004, MacAvon Media Productions XML.
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
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.
CITA 330 Section 2 DTD. Defining XML Dialects “Well-formedness” is the minimal requirement for an XML document; all XML parsers can check it Any useful.
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.
Unit 4 Representing Web Data: XML
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Session III Chapter 6 – Creating DTDs
Chapter 7 Representing Web Data: XML
Session II Chapter 6 – Creating DTDs
Document Type Definition (DTD)
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, DTD (Document Type Definition) –XSchema –XPath, XPointer –XInclude –XSLT –XLink

The W3C is the "World Wide Web Consortium", a voluntary association of companies and non-profit organizations. Membership is very expensive but confers voting rights. The decisions of W3C are guided by the Advisory Committee, lead by Tim Berners-Lee. The stages in the life of a W3C Recommendation (REC) Working Draft (maximum gap target: 3 months) Last Call (public comment invited; W3C must respond) Candidate Recommendation (design is stable; implementation feedback invited) Proposed Recommendation (Advisory Committee review) The XML recommendation was written by the W3C's XML Working Group (WG), which has since divided into a number of subgroups.

An XML document is valid if it has an associated document type definition and if the document complies with the constraints expressed in it. The document type definition (DTD) must appear before the first element in the document. The name following the word DOCTYPE in the document type definition must match the name of the root element. tutorial.dtd: tutorial.xml: This is an XML document

An element type has element content if elements of that type contain only child elements (no character data), optionally separated by white space. tutorial.dtd: tutorial.xml: Start End tutorial.xml (with errors, BBB missing): Start

If an element name in the DTD is followed by the star [*], this element can occur zero, once or several times tutorial.dtd: tutorial.xml: Start Again End The root element XXX can contain zero or more elements AAA followed by precisely one element BBB. Element BBB must be always present.:

If an element name in the DTD is followed by the plus [+], this element can occur once or several times. tutorial.dtd: tutorial.xml: Start Again End tutorial.xml (with errors, AAA must occur at least once): End

If an element name in the DTD is followed by the question mark [?], this element can occur zero or one times. tutorial.dtd: tutorial.xml: End This example uses a combination of [ + * ?] How could a valid document look like?

With the character [ | ] you can select one from several elements. test.dtd: test.xml: Valid The root element XXX must contain either one element AAA or one element BBB: test.xml: Also Valid Text can be interspersed with elements.

Attributes are used to associate name-value pairs with elements. Attribute specifications may appear only within start-tags and empty-element tags. The declaration starts with !ATTLIST followed by the name of the element (myElement) to which the attributes belong to, followed by the definition of the individual attributes (myAttributeA, myAttributeB). Text

An attribute of type CDATA may contain any arbitrary character data, given it conforms to well formedness constraints. Type NMTOKEN can contain only letters, digits and point [. ], hyphen [ - ], underline [ _ ] and colon [ : ] NMTOKENS can contain the same characters as NMTOKEN plus whitespaces. White space consists of one or more space characters, carriage returns, line feeds, or tabs. <!ATTLIST taskgroup group CDATA #IMPLIED purpose NMTOKEN #REQUIRED names NMTOKENS #REQUIRED>

The value of an attribute of type ID may contain only characters permitted for NMTOKEN and must start with a letter. No element type may have more than one ID attribute specified. The value of an ID attribute must be unique between all values of all ID attributes (in the document!).

The value of an attribute of type IDREF has to match the value of some ID attribute in the document. The value of an IDREF attribute can contain several references to elements with ID attributes separated by whitespaces.

Permitted attribute values can be defined in the DTD If an attribute is implied, a default value can be provided in case the attribute isn't used. #Required: You must set the attribute #Implied: You can set the attribute

An element can be defined as EMPTY. In such a case it may contain attributes only but no text. Hello! Are there errors in this example? Where are they?

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 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. <AAAxsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi=" 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. <AAAxsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="

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. <AAA xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi=" > 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? <AAAxsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi=" aaa

In XML Schema, the datatype is referenced by the QName. The namespace must be mapped to the prefix. <rootxsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi=" 25

Restricting simpleType is relatively easy. Here we will require the value of the element "root" to be integer and less than 25. <rootxsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi=" 25 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 <root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi=" 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". <root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi=" > Valid document from the previous Schema!

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. <Axsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi=" > abc