420 likes | 514 Vues
XML and Databases Exercise Session 3 (courtesy of Ghislain Fourny/ETH). Good to know: XML Schema types. Simple type - predefined or user-defined - element or attribute type Complex type - user-defined - element type only Empty content Simple content Complex content Mixed content.
E N D
XML and DatabasesExercise Session 3(courtesy of Ghislain Fourny/ETH)
Good to know: XML Schema types • Simple type - predefined or user-defined - element or attribute type • Complex type - user-defined - element type only • Empty content • Simple content • Complex content • Mixed content
Good to know: XML Schema types • Types (can) have QNames: • All predefined types • User-defined types (here simple) Tags, attributes... XML Schema looks like XML... that's because it is XML!
Good to know: XML Schema types • They can also be anonymous. Anonymous types can be defined under any xs:element or xs:attribute. Non-anonymous types have a global scope and must be defined directly under xs:schema.
Complex types in XML Schema • Complex type, complex content
Complex types in XML Schema • Simple content (here anonymous)
Complex types in XML Schema • Empty content • Simple content restricted to "" • Or a complex content without any children • Mixed content • As in complex content, with an additional attribute mixed set to true in xs:complexType
Exercises 1-3 • Passenger • Flight • Airport • Booking
Exercises 1-3 • Passenger: name, address, passport number • Flight: ID, number of seats, date, origin, dest • Airport: name, code, tax value • Booking: credit card, flight, passenger
Exercise 1: XML Data • Sample data
Exercise 1: XML Data • How to prevent this?
Exercise 1: XML Data • How to prevent this? • With a DTD/Schema!
Exercise 2: XML Schema Modelling Passenger Passport number address name
Exercise 2: XML Schema Modelling code name tax Airport Passenger Passport number address name
Exercise 2: XML Schema Modelling code seatNo flightID name date tax Flight Airport Passenger Passport number address name
Exercise 2: XML Schema Modelling code seatNo flightID name date tax source Flight Airport dest Passenger Passport number address name
Exercise 2: XML Schema Modelling code seatNo flightID name date tax source Flight Airport dest book credit card Passenger Passport number address name
Exercise 2: XML Schema Modelling code seatNo flightID name date tax 1 N source Flight Airport N dest M 1 book credit card N Passenger Passport number address name
Exercise 2: A Schema for Passenger Passenger Passport number address name
Exercise 2: A Schema for Passenger Passenger Passport number address name
Exercise 2: A Schema for Flight seatNo flightID date source Flight Airport dest
Exercise 2: A Schema for Flight seatNo flightID date source Flight Airport dest
Exercise 2: A Schema for Flight seatNo flightID date source Flight Airport dest
Exercise 2: A Schema for Flight seatNo flightID date source Flight Airport dest
Exercise 2: A Schema for Airport code name tax Airport
Exercise 2: A Schema for Airport code name tax Airport
Exercise 2: A Schema for Airport code name tax Airport