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) - 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 ...

95KB Sizes 1 Downloads 223 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)
Nov 26, 2007 - Different companies all proposed different variations of ... XML Data (MS, Arbortext, Inso), January 1998 ... Storage of application information ...

anchor.svg 1/1 - Fas Harvard
anchor.svg. 1/1 examples6/svg/. 1: 2:

foo.xml 1/1 - Fas Harvard
15: * characters are displayed as "\n", "\t", and "\r". 16: * explicitly, and line numbers are reported in errors. 17: *. 18: * @author Computer Science E-259. 19: **/.

books.xml 1/1 - Fas Harvard
2: . 3: DOCTYPE emails SYSTEM "emails.dtd">. 4: . 5:

README.txt 1/2 - Fas Harvard
3: Computer Science E-259. 4: 5: 6: OVERVIEW. 7: 8: In these directories are ... 13: * @author Computer Science E-259. 14: **/. 15: 16: public class TaxClient.

DiagServer.java 1/2 - Fas Harvard
DiagServer.java. 2/2 examples7/. 46: byteCount++;. 47: System.out.write(b); ... 2:

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 ...

AttributeConverter1.xsl 1/2 - Fas Harvard
2/2 examples5/. 46: . 47: .... 2/2 examples5/. 44: 45: . 46: 47: . 48:  ...

Computer Science E-259 - Fas Harvard
“SVG is a language for describing two-dimensional graphics in XML. SVG allows ... Adapted from http://www.adobe.com/svg/basics/getstarted2.html. Viewable at ...

Computer Science E-259 - Fas Harvard
Computer Science E-259. XML with Java, Java ... Computer. Laptop. PDA. Web Server. JSP/servlet. JSP/servlet. EJB Server. EJB. EJB. DB. XML? ... Page 10 ...

Computer Science E-259 - Fas Harvard
Apr 13, 2005 - 1. Copyright © 2007, David J. Malan . All Rights Reserved. Computer Science E-259. XML with Java. Lecture 11:.

Computer Science E-259 - Fas Harvard
Cut through the hype and get to the value. ▫ Focus on. ▫ practicality: what you need to know to do real work. ▫ applications: what are the tools and technologies.

Computer Science E-259 - Fas Harvard
Computer Science E-259. XML with Java. Lecture 5: XPath 1.0 (and 2.0) and XSLT ... All Rights Reserved. Computer Science E-259. Last Time. ▫ CSS Level 2.

Computer Science E-259 - Fas Harvard
Page 2 .... . . .... unidirectional hyperlinks of today's HTML, as well as.

XPath 1.0 (and 2.0) - Fas Harvard
Computer Science E-259. This Time. ▫ CSS Level 2. ▫ XPath 1.0 (and 2.0). ▫ XSLT 1.0 (and 2.0). ▫ TrAX. ▫ Project 2 .... Displaying XML data on the Web as HTML.

Computer Science E-259 - Fas Harvard
All Rights Reserved. Computer Science E-259. XML with Java. Lecture 2: XML 1.1 and SAX 2.0.2. 24 September 2007. David J. Malan [email protected] ...

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

Horario FAS Docente.pdf
TALLER DE LENGUA. Y COMUNICACIÓN I. Código 0103011. Agustín Prado. SEMINARIO DE. PENSAMIENTO LÓGICO. MATEMÁTICO. Código 0207010.

Horario FAS Docente.pdf
Rosa Chavarría. DISEÑO DE. VESTUARIO. Código 0306051. Aurora Ayala. METODOLOGÍA DE. LA DANZA III. Código 0308053. Manuel Stagnaro. KINESIOLOGÍA II. Código 0317052. Moises Del Castillo. PSICOLOGÍA. GENERAL. Código 0201050. Doris Ramírez. HOR

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.