Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.

Similar presentations


Presentation on theme: "Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema."— Presentation transcript:

1 Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema

2 Sheet 2XML Technology in E-Commerce 2001Lecture 2 Logical and Physical Structure of XML Documents; Validity; DTD –Element declarations; –Attribute declarations; XML Schema –Element and Attribute declarations; –Simple types definitions; –Complex types definitions; Lecture Outline

3 Sheet 3XML Technology in E-Commerce 2001Lecture 2 By definition each XML document has logical and physical structure; Markups are used to describe the structures; Two structures must be properly nested according to the specification rules; See “Logical and Physical Structure of XML Documents” Logical and Physical Structure

4 Sheet 4XML Technology in E-Commerce 2001Lecture 2 An XML Document is an information item; Document Logical Structure: represents the information in the way perceived by the user (application); Logical Structure

5 Sheet 5XML Technology in E-Commerce 2001Lecture 2 Physical Structure An XML Document is also a physical entity; The content that we logically perceive can be distributed across several physical entities. They form the physical structure: John Smith John Smith Jr. Entity 1 Entity 2 Entity 3 John Smith John Smith Jr. Logical View

6 Sheet 6XML Technology in E-Commerce 2001Lecture 2 Well-formedness constraints don’t specify element and attribute names and types and the instance document structure; Validity Constraints - specify element and attribute names and types and the document structure; DTD based validation and Schema based validation; Parsers: –Non-validating parsers: check documents for well- formedness; –Validating parsers: check documents for well- formedness and validity constraints; Valid XML Documents

7 Sheet 7XML Technology in E-Commerce 2001Lecture 2 DTD Validation

8 Sheet 8XML Technology in E-Commerce 2001Lecture 2 DTD - Document Type Definition; DTD is a grammar for a class of XML documents; Document Type Declaration: –Contains the DTD for an XML document; –External subset: –Internal subset: <!DOCTYPE root [ ……markup declarations……… ]> DTD

9 Sheet 9XML Technology in E-Commerce 2001Lecture 2 Element type declarations; Attribute list declarations; Entity declarations - declare the entities that form the document physical structure. See “Logical and Physical Structure of XML Documents”; Notation declarations; Document Type Declaration can also contain Processing Instructions and Comments DTD Markup Declarations

10 Sheet 10XML Technology in E-Commerce 2001Lecture 2 Specifies the element type and content: Element’s Content: –Empty: –Any: –Only elements (element content); –Mixed; DTD Element Type Declaration

11 Sheet 11XML Technology in E-Commerce 2001Lecture 2 Content Model Building Blocks: –Choice (p | list | table | form ) –Sequence (street, zip, city, country) –Occurrence Specifiers ? + * Example: See also Deitel 6.4.1, page 139 DTD: Element’s Content Content Model

12 Sheet 12XML Technology in E-Commerce 2001Lecture 2 Elements with mixed content can contain other elements and character data or only character data Other examples - Deitel 6.4.2, page 143 DTD: Element’s Content Mixed Content

13 Sheet 13XML Technology in E-Commerce 2001Lecture 2 Attributes are always associated with a particular element; Attribute list declaration format: <!ATTLIST elName attrName1 attrType1 attrDefault1 attrName2 attrType2 attrDefault2 ………………………………… > Attribute types: –String type; –Tokenized type; –Enumerated type; DTD Attribute List Declaration

14 Sheet 14XML Technology in E-Commerce 2001Lecture 2 String type: Tokenized types: –ID, IDREF, IDREFS (Deitel 6.6.1 page 147); –ENTITY, ENTITIES(Deitel 6.6.1 page 150, “Logical and Physical Structure of XML Documents”); –NMTOKEN, NMTOKENS (Deitel 6.6.1 page 152); Enumerated type: DTD: Attribute Declarations Attribute Types

15 Sheet 15XML Technology in E-Commerce 2001Lecture 2 Provide information about the attribute’s presence: #REQUIRED Attribute must always be present. #IMPLIED The attribute may be absent. There is no default value. Default value DTD: Attribute Declarations Attribute Defaults

16 Sheet 16XML Technology in E-Commerce 2001Lecture 2 DTD is a grammar that specifies element and attributes types and names; DTD contains declarations for Entities and Notations that are used in the document physical structure (see “Logical and Physical Structure of XML Documents”); Mixed element content can not constrain the order of sub- elements; Attribute value type set doesn’t contain primitive data types like integer, date, time, etc. Demo - DTD validation with XML Spy Summary on DTD validation Read: Deitel 6, “Logical and Physical Structure of XML Documents” Assignment: Deitel Ex 6.6 and Ex 6.7, page 164

17 Sheet 17XML Technology in E-Commerce 2001Lecture 2 Logical and Physical Structure of XML Documents; Validity; DTD –Element declarations; –Attribute declarations; XML Schema –Element and Attribute declarations; –Simple types definitions; –Complex types definitions; Lecture Outline

18 Sheet 18XML Technology in E-Commerce 2001Lecture 2 Schema Validation

19 Sheet 19XML Technology in E-Commerce 2001Lecture 2 XML Schema constrains the structure, element and attributes names and types of XML documents; There are several schema proposals. We will discuss W3C Schema; Schema specification defines an abstract data model for schemas and the correspondent XML representation; A schema is a set of components; There are 13 schema components divided into three groups: –Primary components; –Secondary components; –Helper components; XML Schema

20 Sheet 20XML Technology in E-Commerce 2001Lecture 2 Schema: XML Representation schema element Current namespace URI (30 March, no support in XML Spy 3.5 ): http://www.w3.org/2001/XMLSchema Components: –Element declarations; –Attribute declarations; –Simple type definitions; –Complex type definitions;

21 Sheet 21XML Technology in E-Commerce 2001Lecture 2 Syntax : Occurrence: minOccurs and maxOccurs attributes <element ref=“myElement” minOccurs=“2” maxOccurs=“12”/> <element ref=“myElement” minOccurs=“0” maxOccurs=“unbounded”/> Schema Element Declaration

22 Sheet 22XML Technology in E-Commerce 2001Lecture 2 Schema Attribute Declaration (1) Syntax : Defaults: use and value attributes <attribute ref=“myAttr” use=“default” value=“37”/> <attribute ref=“myAttr” use=“fixed” value=“37”/>

23 Sheet 23XML Technology in E-Commerce 2001Lecture 2 Schema Attribute Declaration (2) Changes in attribute occurrence constraints syntax (made on 30 March, currently not supported by XML Spy 3.5) Defaults: use, default, fixed attributes <attribute ref=“myAttr” use=“optional” default=“37”/>

24 Sheet 24XML Technology in E-Commerce 2001Lecture 2 XML Schema provides two kinds of type definition: –Simple types - specify constraints on strings that can be used as values of attributes and elements with only character data content; –Complex types - specify attributes and content model of document elements; Type definition hierarchy: –Types defined by restriction; –Types defined by extension; –Root type - anyType; Schema Type Definitions

25 Sheet 25XML Technology in E-Commerce 2001Lecture 2 Usage - for attribute values and content of elements without attributes and children; 222-33-22-444-1 23 Set of built-in simple datatypes defined in XML Schemas: Datatypes specification (see XML Primer, Appendix B, Table b1.a); Each simple type is a restriction of another simple type; Schema Simple Types

26 Sheet 26XML Technology in E-Commerce 2001Lecture 2 Syntax: content: (restriction | union | list) Restrictions: Facets (see XML Schema Primer, Appendix B); List and Union Types (see XML Schema Primer 2.3.1 and 2.3.2); Schema Simple Type Definition

27 Sheet 27XML Technology in E-Commerce 2001Lecture 2 Complex type definition contains a set of attribute declarations and content model that specify the content and attributes of a set of elements; Complex type can be: –a restriction of another complex type; –an extension of a simple or complex types; –a restriction of the anyType type; Extension mechanism adds additional content parts at the end of the content model of the base definition and/or adds new attribute declarations; Schema Complex Types

28 Sheet 28XML Technology in E-Commerce 2001Lecture 2 Elements with text-only content and attributes. Extension of simple types: 125 Schema Complex Type Definition

29 Sheet 29XML Technology in E-Commerce 2001Lecture 2 Model Group Elements (see XML Schema Primer 2.7): –sequence; –choice; –all; –group; Mixed Content; Empty Elements (see XML Schema Primer 2.5.3) Schema Element Content Model

30 Sheet 30XML Technology in E-Commerce 2001Lecture 2 Anonymous Types (Primer 2.4); Attribute Groups (Primer 2.8); Namespace (Primer 3.1); Deriving types by extension (Primer 4.2); Schema modularization (Primer 4.1); Annotations (Primer 2.6); Relating schema and document instances (Primer 5.6, Deitel 7.6) Demo: Schema validation with XML Spy Schema Additional Features

31 Sheet 31XML Technology in E-Commerce 2001Lecture 2 Expressed in XML; Based on the explicit notion of types for elements and attribute values; Provides namespace control; Uses extension and restriction for type derivation; Lacks of support for entities; Summary on XML Schema Read: Deitel 7, XML Schema Primer (24.10.2000 version) Skip: Deitel 7.3..7.5, Primer 5.1..5.3, 5.5 Assignment:Write schema for planner.xml (Deitel 5.9, page 126) and compare with the syntax in Deitel 7.7. Validate with XML- Spy. Use Chapter 2 and Appendix B from the Primer, Deitel 7.6


Download ppt "Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema."

Similar presentations


Ads by Google