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.

Computer Science E-259

Dec 3, 2007 - List of (extension | restriction | substitution)) default = string final = (#all | List of (extension | restriction)) fixed = string form = (qualified | unqualified) id = ID. maxOccurs = (nonNegativeInteger | unbounded) : 1. minOccurs = nonNegativeInteger : 1 name = ...

155KB Sizes 1 Downloads 337 Views

Recommend Documents

The Future of Computer Science - Cornell Computer Science
(Cornell University, Ithaca NY 14853, USA). Abstract ... Where should I go to college? ... search engine will provide a list of automobiles ranked according to the preferences, .... Rather, members of a community, such as a computer science.

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.

Computer Science E-259
Jan 7, 2008 - Yahoo! UI Library http://developer.yahoo.com/yui/ ..... how to program in JavaScript and PHP, how to configure. Apache and MySQL, how to ...

Computer Science E-259
Nov 19, 2007 - labeling the information content of diverse data sources .... .... ELEMENT article (url, headline_text, source, media_type, cluster,.

TEXTS IN COMPUTER SCIENCE
Java — Designed as a language to support mobile programs, Java has special .... We offer a few low-level coding hints that are helpful in building quality programs. ...... cheap in selecting your table size or else you will pay the price later.

Computer Science E-259
Oct 1, 2007 - DOCTYPE students SYSTEM "student.dtd">.

Computer Science E-259
Nov 29, 2007 - these foundations, the course will explore in detail a number of case studies that utilize XML in e-business: e-commerce, web personalization, ...

Computer Science E-259
Oct 1, 2007 - By Definition. ▫ The result of parsing a document with a DOM parser is a. DOM tree that matches the structure of that document. ▫ After parsing is ...

COMPUTER SCIENCE - Pune University
Poona College of Arts, Science and Commerce, Pune 411 001. 7. 001. 070 ... Sinhagad Technical Education Society's B.C.S. College, Pune 411 041.( 878-.

Computer Science E-259
Dec 3, 2007 - Redefines simple and complex types, groups, and attribute groups from an external schema redefine. Describes the format of non-XML data ...

BS Computer Science - GCUF
Nov 1, 2015 - GOVERNMENT COLLEGE UNIVERSITY, FAISALABAD. 2nd MERIT LIST OF BS Computer Science (EVENING). FOR FALL, 2015-2016.

Computer Science E-259
Nov 19, 2007 - ELEMENT article (url, headline_text, source, media_type, cluster, tagline, document_url ... http://www.oasis-open.org/specs/index.php#dbv4.1.

Computer Science E-259
Oct 22, 2007 - Computer Science E-259. XML with Java. Lecture 5: ... XPath 1.0. ▫ Location Paths. ▫ Data Types ... Data Types. ▫ boolean. ▫ number. ▫ string.

Computer Science E-259
Nov 29, 2007 - students with previous Java programming and web development experience, this course introduces XML as a key enabling technology in today's e-business applications. Students will learn the fundamentals of XML: schemas, XSL stylesheets,

Computer Science E-259
Oct 22, 2007 - 6. Copyright © 2007, David J. Malan . All Rights Reserved. XSLT 1.0, Continued. Data Types. ▫ boolean. ▫ number. ▫ string. ▫ node-set. ▫ external object. ▫ result tree fragment ...

Computer Science E-259
Jan 7, 2008 - . 4019 2445 .... with SQL, and how to use Ajax with both XML and JSON. The course ...

Computer Science E-259
Oct 1, 2007 - structure and content of an XML document. ▫ SAX does this by the type and order of events that are invoked. ▫ DOM does this by using objects in ...

BS Computer Science - GCUF
Nov 1, 2015 - GOVERNMENT COLLEGE UNIVERSITY, FAISALABAD. 2nd MERIT LIST OF BS Computer Science (EVENING). FOR FALL, 2015-2016.

TEXTS IN COMPUTER SCIENCE
thousand bright students, so look there for errata and revised solutions. ..... content, just like the house numbers on a street permit access by address, not ...

pdf-1466\communication-networks-computer-science-computer ...
... of the apps below to open or edit this item. pdf-1466\communication-networks-computer-science-computer-networking-by-cram101-textbook-reviews.pdf.

computer / information technology / computer science & engineering
GUJARAT TECHNOLOGICAL UNIVERSITY. B.E Semester: 4. Computer Engineering/ Computer Science & Engineering/. Information Technology. Subject Name ...