Download presentation
Presentation is loading. Please wait.
1
1 Print your own copy If you bring it along, hand in with your exam script Do not write anything extra or you will be penalized Student Name: Student Number: CSIT600b: XML Programming Syntax Guide for Exam, Fall 2004
2
Dickson Chiu 2004CSIT600b 01-2 DTD DTDs are specified using Internal DTD: ]> External DTD:
3
Dickson Chiu 2004CSIT600b 01-3 Element Type Declarations The line in red is an ETD: ]> #PCDATA means “parsable character data” that will be parsed and hence characters such as, &, etc. will be specially treated EMPTY – no content allow ANY – anything allowed (poor design) Dietel Fig. 6.1 & 6.2 ( intro.xml and intro.dtd ) intro.dtdintro.xml Welcome to XML!
4
Dickson Chiu 2004CSIT600b 01-4, | + * ?, Sequence | Choice + One or more * Zero or more ? Zero or one
5
Dickson Chiu 2004CSIT600b 01-5 Attribute Declarations CDATA for non-parsed character data except, &, ‘ and “ #REQUIRED: attribute must be provided #IMPLIED : application can derive its values if attribute does not appear #FIXED : only 1 possible value as specified if the attribute presents
6
Dickson Chiu 2004CSIT600b 01-6 Attribute Types ID - key uniquely identifies an element IDREF – points to elements with ID attribute Enumerated attribute types (with default values) <!DOCTYPE bookstore [ <!ATTLIST book shippedBy IDREF #IMPLIED> ]> 2 to 4 days 1 day Java How to Program 3rd edition. C How to Program 3rd edition.
7
Dickson Chiu 2004CSIT600b 01-7 More Attribute Types NMTOKEN / NMTOKENS – name token / tokens, each consists of only letters, digits, periods, periods, underscores, hyphens and colon Conforming element: Attribute need not start with a letter ENTITY – attribute must be a declared entity referring to external unparsed entity Conforming element: ENTITIES – one or more of the above ENTITY Conforming element: (Assume city, boat, train are declared entities.)
8
Dickson Chiu 2004CSIT600b 01-8 XML Schema – Simple Types Elements that do not contain other elements or attributes are of type simpleType. Attributes must be defined last:
9
Dickson Chiu 2004CSIT600b 01-9 XML Schema – Enumeration Types xsd:schemaxsd:elementnamexsd:simpleTypexsd:restrictionbasexsd:enumerationvaluexsd:enumerationvaluexsd:restrictionxsd:simpleTypexsd:elementxsd:schema
10
Dickson Chiu 2004CSIT600b 01-10 XML Schema – Range Restrictions Element "root" to be from the range 0-100 or 300-400 (including the border values). xsd:schemaxsd:elementnamexsd:simpleTypexsd:unionxsd:simpleTypexsd:restrictionbasexsd:minInclusivevaluexsd:maxInclusivevaluexsd:restrictionxsd:simpleType xsd:restrictionbasexsd:minInclusivevaluexsd:maxInclusivevaluexsd:restrictionxsd:simpleTypexsd:unionxsd:simpleTypexsd:elementxsd:schema
11
Dickson Chiu 2004CSIT600b 01-11 XML Schema – Complex Types Elements that contain other elements are of type complexType. List of children of complex type are described by all – must all appear, any order sequence –must all appear according to specified sequence choice – any can appear
12
Dickson Chiu 2004CSIT600b 01-12 Cardinality Cardinality of an element can be represented using attributes minOccurs and maxOccurs (default 1). To represent an optional element, set minOccurs to 0; to indicate there is no maximum number of occurrences, set maxOccurs to “unbounded”. <xsd:element name=“DOB” type=“xsd:date” minOccurs = “0”/> <xsd:element name=“NOK” type=“xsd:string” minOccurs = “0” maxOccurs = “3”/>
13
Dickson Chiu 2004CSIT600b 01-13 References Can use references to elements and attribute definitions. …. If there are many references to STAFFNO, use of references will place definition in one place and improve the maintainability of the schema.
14
Dickson Chiu 2004CSIT600b 01-14 Defining New Types Can also define new data types to create elements and attributes. xsd:simpleTypenamexsd:restrictionbasexsd:totalDigitsvaluexsd:fractionDigitsvaluexsd:restrictionxsd:simpleType xsd:simpleTypenamexsd:restrictionbasexsd:patternvaluexsd:restrictionxsd:simpleType
15
Dickson Chiu 2004CSIT600b 01-15 XML Schema Mapping Example Product photoURL : String units : UnitOfMeasure CatalogItem name : String description : String Catalog name : String startDate : Date +item > UnitOfMeasure each dozen 0..* Attribute Association
16
Dickson Chiu 2004CSIT600b 01-16 Product photoURL : String units : UnitOfMeasure CatalogItem name : String description : String Catalog name : String startDate : Date +item > UnitOfMeasure each dozen 0..* Class XML Schema Mapping Example
17
Dickson Chiu 2004CSIT600b 01-17 Product photoURL : String units : UnitOfMeasure CatalogItem name : String description : String Catalog name : String startDate : Date +item > UnitOfMeasure each dozen 0..* Inheritance Enumeration XML Schema Mapping Example
18
Dickson Chiu 2004CSIT600b 01-18 Product photoURL : String units : UnitOfMeasure CatalogItem name : String description : String Catalog name : String startDate : Date +item > UnitOfMeasure each dozen 0..* Enumeration XML Schema Mapping Example
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.