Download presentation
Presentation is loading. Please wait.
Published byHerbert Scot Mosley Modified over 9 years ago
1
www.monash.edu.au CSE3201 Information Retrieval Systems XML Schema – Part 2
2
www.monash.edu.au 2 XML Schema – Part 1 Data Type. Content Model. Relations between data types and content models.
3
www.monash.edu.au 3 XML Schema – Part 2 Anonymous vs Named Type. Derivation of –Simple Type. –Complex Type. Scoping. Designing and Writing XML Schema.
4
www.monash.edu.au 4 Anonymous vs Named Data Type A user-derived data type can be either an anonymous or named data type. A named type allow us to re-use user defined data-types.
5
www.monash.edu.au 5 Anonymous Type A type that is defined without an associated name. Example: <xs:attribute name="language" type="xs:string" use="required"/>
6
www.monash.edu.au 6 Named Type
7
www.monash.edu.au 7 Named Type John Howard George Bush
8
www.monash.edu.au 8 Derived Data Type Derived data types can be created using an extension or restriction methods. Extension is similar to the concept of generalisation in OO modelling. Restriction is similar to the concept of inheritance in OO modelling.
9
www.monash.edu.au 9 Simple Type Derivation Derivation by Restriction. –use the xs:restriction Derivation by List Derivation by Union Derivation by extension is not possible for a simple type.
10
www.monash.edu.au 10 Restriction Restriction can be used to: –specify a range. –specify the length of a string. –specify pattern of a string. –etc
11
www.monash.edu.au 11 Restriction – Range
12
www.monash.edu.au 12 Restriction – Range Restriction –Example : height integer 150 to 250 cm
13
www.monash.edu.au 13 Restriction – Enumerated Values
14
www.monash.edu.au 14 Enumerated Values <size xsi:noNamespaceSchemaLocation="enum.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">XL
15
www.monash.edu.au 15 Restriction - Pattern Victorian Number Plate. –3 digits character followed by 3 digits number.
16
www.monash.edu.au 16 Regular Expression A pattern definition language used to perform pattern matching. Characters used in regular expression: –Bound >{n} specifies the exact number of times for the preceeding item to match. >{n,} specifices the minimum number of times for the preceeding item to match. >{n,m} specifies the minimum(n) and the maximum(m) nuber of times for the preceeding item to match. –?, +, *
17
www.monash.edu.au 17 Regular Expression –Bracket >[] => Matches one of any character enclosed, eg. [abcd] >[lowerBound-upperBound] => Matches any character within the range of lowerBound and upperBound, eg [1-9]. >[^] => Matches any character EXCEPT those enclosed, eg [cat] Examples: –“0{0,2}1?5? >0{0,2} => up to two 0s are permitted. >1?=> 0 or 1 occurrence of the number “1” >5?=> 0 or 1 occurrence of the number “5” >Correct values: 0015, 1, 5 >Incorrect values: 25, 0001
18
www.monash.edu.au 18 Derivation by List Derivation by list is the mechanism by which a list data type can be derived from an atomic data type. All the items in the list need to have the same data type. Example: 5 6 7 8 9 10 11
19
www.monash.edu.au 19 Derivation by List
20
www.monash.edu.au 20 Derivation by Union Derivation by union allows the definition of a new data type by merging of several built-in or user derived data types.
21
www.monash.edu.au 21 Derivation by Union
22
www.monash.edu.au 22 Derivation by Union (con’t)
23
www.monash.edu.au 23 Derivation by Union (con’t)
24
www.monash.edu.au 24 Derivation of a Complex Type Extension –add child-elements >cannot be used in a simple content complex type –add attributes Restriction –removing child-elements or attributes
25
www.monash.edu.au 25 Person Named Type
26
www.monash.edu.au 26 Adding a Child-element
27
www.monash.edu.au 27 Adding an Attribute (1) <!–- Adding an attribute to a simple type to make a complex type
28
www.monash.edu.au 28 Adding an Attribute (2) <!–- adding an attribute to a complex type
29
www.monash.edu.au 29 Removing a Child Element
30
www.monash.edu.au 30 Person with Attribute – Named Type
31
www.monash.edu.au 31 Removing Attribute
32
www.monash.edu.au 32 Scope of a Declaration and Definition An element or an attribute can be declared as either a local or global declaration. An element or attribute declared as a child of a schema declaration is considered as a global element or attribute. An element or attribute declared as a child of another element declaration is considered a local element or attribute.
33
www.monash.edu.au 33 Global Declaration <xs:element name=“yearPublished” type=“xs:gYear”/> Elements author, editor, title and book are global elements. The element yearPublished is a local element.
34
www.monash.edu.au 34 Global or Local Declaration? Russian Doll –Use only the local declarations. Salami –Use only the global declarations. Venetian Blind –Use namedType.
35
www.monash.edu.au 35 Russian Doll Design
36
www.monash.edu.au 36 Salami Design
37
www.monash.edu.au 37 Venetian Design
38
www.monash.edu.au 38 Which one to use? Read –Global versus Local - http://www.xfront.com/GlobalVersusLocal.html#Issue
39
www.monash.edu.au 39 Named Type vs Global Declaration - Schema Named Type <xs:element name="firstname“ type="xs:string"/> <xs:element name="lastname“ type="xs:string"/> <xs:element name=“author” type=“person”/> Global Declaration <xs:element name="firstname“ type="xs:string"/> <xs:element name="lastname“ type="xs:string"/>
40
www.monash.edu.au 40 Named Type vs Global Declaration - XML Named Type <author xsi:noNamespaceSchemaLocation="na medTypeAuthor.xsd" xmlns:xsi="http://www.w3.org/2001 /XMLSchema-instance"> Maria Indrawan Global Declaration <author xsi:noNamespaceSchemaLocation= "authorGlobal.xml“ xmlns:xsi="http://www.w3.org/ 2001/XMLSchema-instance"> Maria Indrawan
41
www.monash.edu.au 41 Steps in Creating an XML Schema Identify possible elements. Visualise the relations between the elements (structure) using a diagram, eg tree diagram. Add attributes or change some elements to attributes when necessary. Consider the application of specific business rules, eg ranges, cardinality. Consider the possibility of re-use for some of the elements/attributes. –Consider named type and global declaration. Write the schema.
42
www.monash.edu.au 42 Writing the Schema Check the writeSchema.pdf.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.