Computer Science E-259 XML with Java, Java Servlet, and JSP

Lecture 9: XML Schema (Second Edition) 26 November 2007 David J. Malan [email protected]

1 Copyright © 2007, David J. Malan . All Rights Reserved.

Last Time XQuery 1.0 and DTD ƒ ƒ ƒ

XQuery 1.0 DTD Project 3

2 Copyright © 2007, David J. Malan . All Rights Reserved.

Last Time XQuery 1.0 and DTD

3

]> My Life and Times Paul McCartney 1998 1-56592-235-2 McMillin Publishing Illusions The Adventures of a Reluctant Messiah Richard Bach 1977 0-440-34319-4 Dell Publishing Co. Adapted from http://www.xfront.com/xml-schema.html. ... Copyright © 2007, David J. Malan . All Rights Reserved.

Computer Science E-259 This Time ƒ ƒ

XML Schema (Second Edition) Project 4

4 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) History ƒ ƒ ƒ

After the release of XML 1.0, DTDs were soon recognized as insufficient Work towards new schema standards began in early 1998 Different companies all proposed different variations of schema formats defined in XML; all submitted as Notes to the W3C ƒ XML Data (MS, Arbortext, Inso), January 1998 ƒ DCD (MS & IBM), June 1998 ƒ XDR (XML Data Reduced), July 1998 ƒ SOX (Schema for OO XML), July 1999

5 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) History ƒ ƒ

W3C Working Group formed to address the schema issue in early 1999 XML Schema became an official recommendation in May 2001; Second Edition in October 2004 ƒ Primer ƒ Structures ƒ DataTypes

6 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) By Example ƒ

Let's look at po.xml and po.xsd

ƒ

Notice that ƒ XML instance points to schema ƒ XML Schema declares elements ƒ XML Schema defines types ƒ Types come in a number of varieties ƒ Built-in types (e.g., xsd:string, xsd:date) ƒ Simple types ƒ Complex types

7 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Why? ƒ

ƒ ƒ ƒ ƒ

Data validation ƒ Structure of elements and attributes ƒ Order of elements ƒ Data values of elements and attributes ƒ Uniqueness of values Establish a contract with trading partners Documentation Augmentation of instance with default values Storage of application information

8 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Another Example

9

557 10 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Declarations v. Definitions ƒ ƒ ƒ

Declarations used for components that can appear in the instance (e.g., elements and attributes) Definitions used for components internal to the schema (e.g., data types and model groups) Order in schema document is insignificant

10 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Global v. Local Components ƒ

ƒ

Global components ƒ Appear at the top level of the schema (children of xsd:schema) ƒ Name must be unique in component type in schema Local components ƒ Scoped to the definition or declaration that contains them ƒ For example, elements declared in the scope of a complex type or types declared anonymously inside other constructs

11 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Element and Attribute Declarations ƒ ƒ

The basic building blocks of XML documents Each associated with a data type ƒ Use different names for data that is structurally the same by sharing a type (e.g., shipTo and billTo both have type USAddress) ƒ Use the same names but two different types in different contexts (e.g., size child of shirt with type xsd:integer or size child of hat with enumerated type "S", "M", "L")

12 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Simple v. Complex Types ƒ

Elements with simple types have character data content but no child elements or attributes 10 Extra trim on sides 10 large 2

ƒ

Elements with complex types can have child elements or attributes 10 Extra trim on sides 10 2

ƒ

Attributes always have simple types

13 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Named v. Anonymous Types ƒ ƒ

Named types are always defined globally and are available for reuse Anonymous types have no names and are local to an element or attribute declaration

14 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Type Definition Hierarchy ƒ ƒ ƒ ƒ

Data types can be derived from other types by restricting or extending In our example, SizeType restricts the range of an integer Complex type UKAddressType can extend AddressType by adding more children Most importantly, a subtype can be substituted when a base type is expected (a UKAddressType is valid when AddressType is expected)

15 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Simple Types ƒ

ƒ ƒ

Built-In Data Types ƒ string-related ƒ ENTITIES, ENTITY, ID, IDREF, IDREFS, language, Name, NCName, NMTOKEN, NMTOKENS, normalizedString, QName, string, token ƒ Date-related ƒ date, dateTime, duration, gDay, gMonth, gMonthDay, gYear, gYearMonth, time ƒ Number-related ƒ base64Binary, byte, decimal, double, float, hexBinary, int, integer, long, negativeInteger, nonPositiveInteger, positiveInteger, short, unsignedLong, unsignedInt, unsignedShort, unsignedByte ƒ Err, unrelated ƒ anyURI, boolean, NOTATION, ... New simple types can be derived from built-in ones by restricting them along some facets (e.g., minInclusive) Most simple types are atomic types but we can also have: ƒ List types: whitespace-separated lists of atomic values ƒ Union types: have a value picked from a set of types

16 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Complex Types ƒ ƒ ƒ

Contents of an element are character data and child elements Four different content types: ƒ Simple, Element, Mixed, Empty Content Models describe the order and structure of child elements of a complex type ƒ sequence groups specify order ƒ choice groups allow one of several options ƒ all groups require all child elements appear 0 or 1 times in any order

17 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Another Example

18 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Namespaces ƒ ƒ

Namespaces are used heavily in XML Schema, so let's review A namespace is bound to a URI such as http://example.org/prod or urn:example:org

ƒ

An instance can include one or more namespace by mapping element prefixes to namespace URIs 557 10

ƒ

Prefix choice doesn't matter; only the mapping to the URI does (conventions exist like xsl:, xsd:)

19 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Multiple Namespaces ƒ

Multiple namespace declarations are easy and useful 123ABBCC123 557 10

ƒ

Note that number appears twice in two different namespaces

20 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Default Namespaces ƒ

A default namespace declaration binds elements with no prefix to a namespace 123ABBCC123 557 10

21 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Target Namespaces ƒ ƒ

XML Schema lets you specify at most one namespace as the target namespace All declarations and definitions will be part of the target namespace ...

22 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Relating Instances to Schemas ƒ

There are four ways to relate instances to schemas ƒ Use a hint in the instance (xsi:schemaLocation or xsi:noNamespaceSchemaLocation on root element points to schema) ƒ Let the application choose and pass to schema validator or parser using code ƒ Let the user choose (a dialog for example) ƒ Dereference the namespace URI to locate a schema

23 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Another Example 557 10

24

xsi:schemaLocation="http://example.org/prod prod.xsd http://example.org/ord ord.xsd" 123ABBCC123 557 10 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) Schema Processors ƒ

XSV (XML Schema Validator) ƒ Not a parser but just a schema validator ƒ http://www.w3.org/2001/03/webdata/xsv

ƒ

Xerces ƒ Turn on parser feature asking for validation Stylus Studio XMLSpy ...

ƒ ƒ ƒ

25 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition) The BookStore, Revisited My Life and Times Paul McCartney 1998 1-56592-235-2 McMillin Publishing Illusions The Adventures of a Reluctant Messiah Richard Bach 1977 0-440-34319-4 Dell Publishing Co. ...

26

Adapted from http://www.xfront.com/xml-schema.html.

Copyright © 2007, David J. Malan . All Rights Reserved.

Project 4

27 Copyright © 2007, David J. Malan . All Rights Reserved.

Next Time XML Schema 1.0, Continued ƒ ƒ ƒ ƒ

Datatypes Structures Simple Types Complex Types

28 Copyright © 2007, David J. Malan . All Rights Reserved.

Computer Science E-259 XML with Java, Java Servlet, and JSP

Lecture 9: XML Schema (Second Edition) 26 November 2007 David J. Malan [email protected]

29 Copyright © 2007, David J. Malan . All Rights Reserved.

XML Schema (Second Edition)

Nov 26, 2007 - Different companies all proposed different variations of ... XML Data (MS, Arbortext, Inso), January 1998 ... Storage of application information ...

95KB Sizes 2 Downloads 271 Views

Recommend Documents

XML Schema (Second Edition) - Fas Harvard
Establish a contract with trading partners. ▫ Documentation. ▫ Augmentation of instance with default values. ▫ Storage of application information ...

XML Schema (Second Edition) - Fas Harvard
After the release of XML 1.0, DTDs were soon recognized as insufficient. ▫ Work towards new schema standards began in early 1998. ▫ Different companies all ...

XML Schema - Computer Science E-259: XML with Java
Dec 3, 2007 - ..... An all group is used to indicate that all elements should appear, in any ...

pdf-32\xml-schema-the-w3cs-object-oriented ...
Page 1 of 8. XML SCHEMA: THE W3C'S OBJECT- ORIENTED DESCRIPTIONS FOR XML BY. ERIC VAN DER VLIST. DOWNLOAD EBOOK : XML SCHEMA: ...

XML schema refinement through redundancy detection ... - Springer Link
Feb 20, 2007 - egy to avoid data redundancies is to design redundancy-free schema from the ...... nodesCN,C A, andCNA are removed becauseC is an XML. Key. ..... the name element of province and the country attribute of city together ...

A novel method for measuring semantic similarity for XML schema ...
Enterprises integration has recently gained great attentions, as never before. The paper deals with an essential activity enabling seam- less enterprises integration, that is, a similarity-based schema matching. To this end, we present a supervised a

My First XML Parser
Oct 15, 2007 - Computer Science E-259: XML with Java, Java Servlet, and JSP .... phones didn't exist in 1636, so the course hadn't a phone number on file for.

XML programming with SQL/XML and XQuery
agers fulfill vital responsibilities in complex informa- tion systems by ... other information-service systems. Permission to ...... Client, network, and server resources ...

XML programming with SQL/XML and XQuery - IEEE Xplore
XML programming model evolution. SAX (the simple API [application programming in- terface] for XML)1 was the first popular interface for. XML programming.

Image Schema
through space, our manipulations of objects, and our perceptual interactions” (1987: 29). Image schemas behave as .... insofar as they constitute 'spaces' sectioned into areas without specifying actual magnitude, shape, or material. Lack of ......

XML Tooling - Sites
J2EE Tooling (2 of 2). Connector Projects. J2EE Connector Architecture (JCA) based. EJB Test Client – Universal Test Client. HTML-based. J2EE programming ...

My First XML Parser
Oct 15, 2007 - Consider now a larger excerpt from CSCI E-259's original database, the .... element can be printed as a start tag immediately followed by an ...

Learning XML
Extensible Markup Language (XML) is a data storage toolkit, a configurable vehicle for any kind of information, an .... computer programs to determine the functions and boundaries of document parts. ...... so perhaps the backup is a good idea.

pdf xml php
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. pdf xml php.

Second Edition
Internet Mail Protocols . ...... Houston. With over two decades of full-time experience in information technology, .... signed to be small, fast, and inexpensive. So far ...

Introduction to XML
Industry standards and data exchange applications. 2. Web services, SOA data transport and message ... e.g., Phone numbers (home, office, mobile), in patient.

CMDBuild database schema -
Application. Application ... InfrastructureSW. Infrastructure software ...... Apple. Apple. HP. HP. IBM. IBM. Sony. Sony. SAP. SAP. CMDBuild. CMDBuild. CI - State.

LDAP Schema Design
Schema is the term used to describe the shape of the ... the relational model used by most well-known database systems, and this affects the way LDAP .... delegated management: if all the people in the Customer Service Department are .... Used to sto

generate pdf xml
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. generate pdf xml.

Printing Stampa schema -
ESPB266:1L19341. IL19341. Titino.cu. Sheet: /. File: SST_V2.sch. Title: Souiliss Thermostat. Size: A4. Date: 2016-11-08. KiCad E.D.A. eeschema 4.0.4-stable.

pdf export xml
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. pdf export xml.

voice xml pdf
File: Voice xml pdf. Download now. Click here if your download doesn't start automatically. Page 1 of 1. voice xml pdf. voice xml pdf. Open. Extract. Open with.

A Case for XML - IJEECS
With these considerations in mind, we ran four novel experiments: (1) we measured instant messenger and RAID array throughput on our 2-node testbed; (2) we ...