Presentation is loading. Please wait.

Presentation is loading. Please wait.

DSA week 161 XML Data and Schemas DSA Week 16. DSA week 162 News Bloglines wall of images –http://www.bloglines.com/about/wallofimageshttp://www.bloglines.com/about/wallofimages.

Similar presentations


Presentation on theme: "DSA week 161 XML Data and Schemas DSA Week 16. DSA week 162 News Bloglines wall of images –http://www.bloglines.com/about/wallofimageshttp://www.bloglines.com/about/wallofimages."— Presentation transcript:

1 DSA week 161 XML Data and Schemas DSA Week 16

2 DSA week 162 News Bloglines wall of images –http://www.bloglines.com/about/wallofimageshttp://www.bloglines.com/about/wallofimages XML in 2007 –http://www- 128.ibm.com/developerworks/xml/library/x- xml2007predictions.htmlhttp://www- 128.ibm.com/developerworks/xml/library/x- xml2007predictions.html

3 DSA week 163 Agenda Help on Coursework 2 Data / schema distinction Well-formed and valid Different Schema languages Top-down – Using QSEE to create a Schema Bottom-up – Using Trang to generalize Guidelines for a good schema Linking Multiple documents

4 DSA week 164 Coursework :Icons in kml Each Placemark has an icon – by default it is the pin symbol but its easy to change this The full set of Google Earth supplied icons is herehere Define one or more styles in the Folder Link to one of these styles from the Placemark to be styled

5 DSA week 165 Example kml with icon … http://maps.google.com/mapfiles/kml/pal3/icon21.png … …. #home

6 DSA week 166 RDBMS table Data Schema SQL DDL XML document DTD XML Schema Conceptual Model ERM defines realises defines infer

7 DSA week 167 Well-formed and Valid Well-formed –Applies to all XML documents –Tag naming, nesting, attributes and values –An XML-aware programme should be able to read any well- formed XML Valid –The document conforms to a given definition of its structure The names of tags How tags are nested What kinds of values are allowable What multiplicities of children are allowed –A document may conform to any number of different schemas –Validity is not an absolute property

8 DSA week 168 Map layout Top-down –Draw XML model –Generate schema in a schema language Bottom-up –Create some data following a informal pattern or prototype –Use trang (Jim Clark) to infer the schema

9 DSA week 169 Staff Room Tony Solomonides Staff Room Richard Lawson Office Eleanor Gibbons Dee Evans Ali Jack

10 DSA week 1610 Using QSEE to create the schema Start QSEE Select XML data model Name the root entity and then add children When a node is a text node (a leaf) define the data type. Add attributes Multiplicities are added to the parent-child relationship Save the project Generate the XML schema or DTD

11 DSA week 1611

12 DSA week 1612 Languages for defining schemas DTD XML Schema (.xsd) RelaxNG – XML syntax RelaxNG – compact syntax Schematron

13 DSA week 1613 …

14 DSA week 1614 RelaxNG default namespace = "" start = element MapSet { element Map { attribute desc { text }, attribute id { xsd:NCName }, element room { attribute id { xsd:NMTOKEN }, element area { attribute coords { text }, attribute shape { xsd:NCName } }, (element type { text }, element occupant { text }+)? }+ }

15 DSA week 1615 Schema by induction It is possible to deduce some of the structure of a file by induction –If all the children of a node have the same tag name, and the same (or compatible )structure then they are instances of the same element. InfoPath (which creates data entry forms) can induce the structure from an example file Trang is an open source programme written in Java by James Clark –http://www.thaiopensource.com/relaxng/trang.htmlhttp://www.thaiopensource.com/relaxng/trang.html Built into XML IDEs e.g. oXygen

16 DSA week 1616 Designing a Schema My advice for this coursework: –Use elements only, not attributes to simplify the design –Common text values are indicative of a simple enumerated property –Create meaningful names for the tags –Names don’t have to be unique in the hierarchy, only within the parent node If there is redundancy in the data, consider normalising into several files (but you will need to work out how to link the files in PHP)

17 DSA week 1617 Multiple XML documents Simple XML models have a single hierarchy – ok if children are contained within parent – composition relationship More generally, links from one node in a document to other nodes in the same or other documents are required –Emp to dept –Timetable to Bus stop Need to be able to represent associations as well Can use any element or attribute as primary key and foreign key Links can be made between any atomic items (as in SQL) Relationships can be defined and constrained but its not easy

18 DSA week 1618 Rooms and People Normalise the room data to: Room Person ? ?

19 DSA week 1619 Staff Room Staff Room Office Staff Room

20 DSA week 1620 Tony Solominides 81111 2P2 Eleanor Gibbons 85555 2P4 Dee Allan 85566 2P4 Ali Jack 85566 2P4

21 DSA week 1621 What problems? Could remove a room, or change its id when it is referenced by a person RDBMS can detect this and can take action – e.g. forbid the change XML is like the web – no protection Some advances in this area

22 DSA week 1622 Workshop To create a simple XML schema for whisky distilleries Use QSEE to create the model. Create a couple of entries Generate the kml


Download ppt "DSA week 161 XML Data and Schemas DSA Week 16. DSA week 162 News Bloglines wall of images –http://www.bloglines.com/about/wallofimageshttp://www.bloglines.com/about/wallofimages."

Similar presentations


Ads by Google