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

Lecture 10: XML Schema, Continued 3 December 2007 David J. Malan [email protected]

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

Last Time XML Schema (Second Edition) ƒ ƒ

XML Schema (Second Edition) Project 4

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

Last Time

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

Last Time XML Schema (Second Edition) ƒ ƒ ƒ ƒ ƒ ƒ ƒ ƒ ƒ

ƒ

Declarations v. Definitions Global v. Local Components Element and Attribute Declarations Simple v. Complex Types Named v. Anonymous Types Type Definition Hierarchy Simple Types Complex Types Namespaces ƒ Multiple ƒ Default ƒ Target Relating Instances to Schemas

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

Computer Science E-259 This Time ƒ

XML Schema 1.0, Continued

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

Datatypes Built-In

6

Image from http://www.w3.org/TR/xmlschema-2/.

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

Structures Elements

7

Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*)) Excerpted from http://www.w3.org/TR/xmlschema-1/. Copyright © 2007, David J. Malan . All Rights Reserved.

Structures Attributes Content: (annotation?, (simpleType?))

8

Excerpted from http://www.w3.org/TR/xmlschema-1/.

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

Simple Types Elements of Unrestricted, Simple Types ƒ

Canonical Declaration

ƒ

Examples of Instances John Harvard 1636

ƒ

Examples of Declarations

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

Simple Types Attributes of Unrestricted, Simple Types ƒ

Canonical Declaration

ƒ

Example of an Instance John Harvard

ƒ

Example of a Declaration

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

Simple Types Attributes with Default or Fixed Values ƒ

In the absence of a value, a default can be assigned

ƒ

A value, if present and declared fixed, must appear as declared; in the absence of a value, the declared will be assigned

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

Simple Types Optional and Required Attributes ƒ

By default, attributes are optional

ƒ

If declared required, attribute must be present

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

Simple Types Restrictions through Facets

13

Facet

Description

enumeration

Defines a list of acceptable values

fractionDigits

Specifies the maximum number of decimal places allowed. Must be equal to or greater than zero

length

Specifies the exact number of characters or list items allowed. Must be equal to or greater than zero

maxExclusive

Specifies the upper bounds for numeric values (the value must be less than this value)

maxInclusive

Specifies the upper bounds for numeric values (the value must be less than or equal to this value)

maxLength

Specifies the maximum number of characters or list items allowed. Must be equal to or greater than zero

minExclusive

Specifies the lower bounds for numeric values (the value must be greater than this value)

minInclusive

Specifies the lower bounds for numeric values (the value must be greater than or equal to this value)

minLength

Specifies the minimum number of characters or list items allowed. Must be equal to or greater than zero

pattern

Defines the exact sequence of characters that are acceptable

totalDigits

Specifies the exact number of digits allowed. Must be greater than zero

whiteSpace

Specifies how white space (line feeds, tabs, spaces, and carriage returns) are handled

Adapted from http://www.w3schools.com/schema/schema_facets.asp.

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

Simple Types Restricting by Value 14 Copyright © 2007, David J. Malan . All Rights Reserved.

Simple Types Restricting by Value

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

Simple Types Restricting by Value

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

Simple Types Restricting by Pattern

17

Adapted from http://www.w3schools.com/schema/schema_facets.asp.

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

Simple Types Restricting by Pattern

18

Adapted from http://www.w3schools.com/schema/schema_facets.asp.

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

Simple Types Restricting by Pattern

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

Simple Types Regular Expressions

regular expression branch

branch

\d{3}-[A-Z]{2} | \d{7} atom

atom atom

quantifier

atom quantifier

quantifier

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

Simple Types Regular Expressions ƒ

An atom describes one or more character through ƒ a single normal character (e.g., a or c) ƒ a parenthesized regular expression (e.g., (a|c)) ƒ an \n \d \s

escape, such as for newline, \? for ?, . for any character but \n and \r for any digit, \D for any character but a digit for any whitespace character

ƒ a character class expression [abc] matches any of a list of characters [0-9] or [a-z] matched any character from a range ƒ

A quantifier indicates how many times an atom should repeat (e.g., ?, *, +, {n}, {n,}, {n,m})

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

Simple Types Restricting Whitespace

22

Adapted from http://www.w3schools.com/schema/schema_facets.asp.

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

Simple Types Restricting by Length 23

Adapted from http://www.w3schools.com/schema/schema_facets.asp.

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

Simple Types Lists 90 85 77 100 99 45

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

Simple Types Unions 25

Adapted from http://www.w3schools.com/schema/el_union.asp.

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

Complex Types Content Types for Elements ƒ

Simple (i.e., children include text only) Jerry Seinfeld

ƒ

Element-Only (i.e., children include elements only) JerrySeinfeld

ƒ

Mixed (i.e., children contain text and/or elements)

Jerry Seinfeld is a comedian.



ƒ

Empty (i.e., no children)

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

Complex Types Simple Content .... ....

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

Complex Types Element-Only Content John Harvard 1636 28 Copyright © 2007, David J. Malan . All Rights Reserved.

Complex Types Element-Only Content John Harvard 29 Copyright © 2007, David J. Malan . All Rights Reserved.

Complex Types Mixed Content Dear Mr.John Smith. Your order 1032 will be shipped on 2001-07-13. 30

Adapted from http://www.w3schools.com/schema/schema_complex_mixed.asp.

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

Complex Types Empty Content

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

Complex Types Model Groups ƒ ƒ ƒ

A sequence group of element declarations is used to indicate the order in which the elements should appear A choice group of element declarations is used to indicate that only one of the elements should appear An all group is used to indicate that all elements should appear, in any order, but no more than once each

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

Complex Types The sequence Model

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

Complex Types The sequence Model

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

Complex Types The choice Model

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

Complex Types Nesting Models!

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

Complex Types The all Model

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

Complex Types Defining Model Groups 38

Adapted from http://www.w3schools.com/schema/schema_complex_indicators.asp.

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

Complex Types Defining Attribute Groups

39

Adapted from http://www.w3schools.com/schema/schema_complex_indicators.asp.

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

Complex Types Extending Simple Types 40

Adapted from http://www.w3schools.com/schema/el_extension.asp.

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

Complex Types Extending Complex Types

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

Complex Types Allowing for Any Elements

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

Complex Types Allowing for Any Attributes

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

Complex Types Allowing for Substitutes John Smith Giovanni Smith 44

Adapted from http://www.w3schools.com/schema/schema_complex_subst.asp.

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

XML Schema (Second Edition) Summary

45

Element

Explanation

all

Specifies that the child elements can appear in any order. Each child element can occur 0 or 1 time

annotation

Specifies the top-level element for schema comments

any

Enables the author to extend the XML document with elements not specified by the schema

anyAttribute

Enables the author to extend the XML document with attributes not specified by the schema

appInfo

Specifies information to be used by the application (must go inside annotation)

attribute

Defines an attribute

attributeGroup

Defines an attribute group to be used in complex type definitions

choice

Allows only one of the elements contained in the declaration to be present within the containing element

complexContent

Defines extensions or restrictions on a complex type that contains mixed content or elements only

complexType

Defines a complex type element

documentation

Defines text comments in a schema (must go inside annotation)

element

Defines an element

extension

Extends an existing simpleType or complexType element

field

Specifies an XPath expression that specifies the value used to define an identity constraint

Excerpted from http://www.w3schools.com/schema/schema_elements_ref.asp.

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

XML Schema Summary

46

group

Defines a group of elements to be used in complex type definitions

import

Adds multiple schemas with different target namespace to a document

include

Adds multiple schemas with the same target namespace to a document

key

Specifies an attribute or element value as a key (unique, non-nullable, and always present) within the containing element in an instance document

keyref

Specifies that an attribute or element value correspond to those of the specified key or unique element

list

Defines a simple type element as a list of values

notation

Describes the format of non-XML data within an XML document

redefine

Redefines simple and complex types, groups, and attribute groups from an external schema

restriction

Defines restrictions on a simpleType, simpleContent, or a complexContent

schema

Defines the root element of a schema

selector

Specifies an XPath expression that selects a set of elements for an identity constraint

sequence

Specifies that the child elements must appear in a sequence. Each child element can occur from 0 to any number of times

simpleContent

Contains extensions or restrictions on a text-only complex type or on a simple type as content and contains no elements

simpleType

Defines a simple type and specifies the constraints and information about the values of attributes or text-only elements

union

Defines a simple type as a collection (union) of values from specified simple data types

unique

Defines that an element or an attribute value must be unique within the scope

Excerpted from http://www.w3schools.com/schema/schema_elements_ref.asp.

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

Next Time Web Services, SOAP 1.2, and WSDL 1.1

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

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

Lecture 10: XML Schema, Continued 3 December 2007 David J. Malan [email protected]

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

XML Schema - Computer Science E-259: XML with Java

Dec 3, 2007 - use="optional"/> ..... An all group is used to indicate that all elements should appear, in any ...

155KB Sizes 2 Downloads 305 Views

Recommend Documents

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

Computer Science E-259 XML with Java Lecture 2
Sep 24, 2007 - This is an XML document that describes students -->.

Syllabus - Computer Science E-259: XML with Java
Oct 15, 2007 - ... standard APIs like JAXP and TrAX, and industry-standard software like Ant, Tomcat, ..... XSLT: Programmer's Reference, Second Edition.

Computer Science E-259 Lectures - Computer Science E-259: XML ...
Sep 17, 2007 - most important new technology development of the last two years." Michael Vizard ... applications: what are the tools and technologies necessary to put ... XML. When. ▫ The World Wide Web Consortium (W3C) formed an XML.

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

Computer Science E-259 XML with Java Lecture 4: XPath 1.0
Computer Science E-259. XML with Java. Lecture 4: XPath 1.0 (and 2.0) and XSLT 1.0 (and 2.0). 15 October 2007. David J. Malan [email protected] ...

Computer Science E-259 XML with Java Lecture 11: Web Services ...
Apr 13, 2005 - All Rights Reserved. Computer Science E-259. XML with Java. Lecture 11: Web Services, SOAP 1.2, and WSDL 1.1. 10 December 2007.

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.

pdf to xml converter java
Page 1. Whoops! There was a problem loading more pages. pdf to xml converter java. pdf to xml converter java. Open. Extract. Open with. Sign In. Main menu.

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

pdf to xml conversion java
Sign in. Loading… Whoops! There was a problem loading more pages. Retrying... Whoops! There was a problem previewing this document. Retrying.

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