Presentation is loading. Please wait.

Presentation is loading. Please wait.

UFIEKG-20-2 / 06 / Week 131 Data, Schemas and Applications Term 2 Week 13.

Similar presentations


Presentation on theme: "UFIEKG-20-2 / 06 / Week 131 Data, Schemas and Applications Term 2 Week 13."— Presentation transcript:

1 UFIEKG-20-2 / 06 / Week 131 Data, Schemas and Applications Term 2 Week 13

2 UFIEKG-20-2 / 06 / Week 132 Agenda Plan for the term Coursework RSS as an example of an XML ‘standard’ Recap on XML –Naming the parts –Tree structure Namespaces XML processing

3 UFIEKG-20-2 / 06 / Week 133 Lecture plan Focus on XML and XML processing Contrast data representation in relational database and XML formats Develop small mash-ups, multi-media and multi modal web applications

4 UFIEKG-20-2 / 06 / Week 134 Coursework Individual Work sheets in tutorials will contribute to coursework Structure the workload through the term to avoid overload last two weeks of term Try to keep the final task of manageable yet rewarding size

5 UFIEKG-20-2 / 06 / Week 135 RSS (1) Problem: –I want to disseminate news about my project/company, and allow interested people to read it. –e.g. the module blog needs to have new items read by students and staff Solution 1 –I publish a page of news on my website Problems 1 –how do readers know when its changed –content cannot be computer-processed

6 UFIEKG-20-2 / 06 / Week 136 RSS (2) Solution 2 –I make up my own XML vocabulary –Generate a file for a program to consume Problem 2 – A reader has to be able to understand my format – and many others! –How is this file discovered?

7 UFIEKG-20-2 / 06 / Week 137 RSS (3) Solution 3 –Standardise on one (or 4!) general formats of news feed, so that any reader can understand it –RSSRSS Really Simple Syndication Rich Site Summary Characteristics –Basic content are items in reverse chronological order –Some basic tags such as links back to the full story.

8 UFIEKG-20-2 / 06 / Week 138 RSS (4) Problems for the reader –I want to read news from many sources –I want to be able to distinguish items I’ve read for ones I haven’t –I want to know when new items are published –I want to be able to find feeds which are interesting to me –I want to restrict the items in the feed to those which interest me Problem for the provider –Many readers continually asking for the latest news will generate a high demand on providers Partial Solution –Reader needed which Is stateful – remembers what items have been read Integrates multiple feeds into one compendium Polls news provider on a regular basis –Feed integrators Bloglines, Google Reader, reduce the load on the provider and provide some filtering How it works –SlideshowSlideshow

9 UFIEKG-20-2 / 06 / Week 139 Understanding an XML file Naming the parts – indicate on the listing one example of each of the following: –Document –Root Element –Element Name Content –Attribute Name Value –Character Entity Reference –Processing Instruction –Character set

10 UFIEKG-20-2 / 06 / Week 1310 XML as a tree Draw a tree structure of this document. What is the parent on the item element? What are the children of the rss element?

11 UFIEKG-20-2 / 06 / Week 1311 Namespaces Problem: To allow multiple languages (which may use the same word for different things) to be merged in one document. –Solution : mixing HTML and PHP in the same document using boundary markers: – to leave –Namespaces are another solution – each item is qualified by a namespace identifier XML Namespaces –In the document, a prefix to the tag qualifies the tag name –The prefix is just an abbreviation – what matters is the URI it is associated with by a pseudo attribute e.g. xmlns:geo=“http://www.w3.org/2003/01/geo/wgs84_pos#”http://www.w3.org/2003/01/geo/wgs84_pos# –Default namespace may be set on an element to avoid repeating it on all children xmlns='http://www.w3.org/2005/Atom'

12 UFIEKG-20-2 / 06 / Week 1312 Transforming XML A common task in web applications is to take one or more XML documents and transform the information to a different structure Transform a.XML b.XML Filter, restructure, calculate

13 UFIEKG-20-2 / 06 / Week 1313 XML transformation Input –A local file –A dynamic file (e.g. via AJAX) –A remote file (accessed by HTTP) –A part of a database Transform –JavaScript and DOM - see ZIP example –XSLT (an XML vocabulary) –Java + XML (JAXP) –PHP + SimpleXML –XQuery –…–… Location On the server On the client In the database Requires ‘well-formed XML’

14 UFIEKG-20-2 / 06 / Week 1314 PHP and XML SimpleXML –Load document and construct a tree of objects in one operation $rss = simplexml_load_file(..) –CEMS server behind a proxy so access is a little more complicated –Access child elements using object reference notation $item = $rss ->channel ->item –Access child elements in a namespace $geo = $item->children(“ http://www.w3.org/2003/01/geo/wgs84_pos#”) http://www.w3.org/2003/01/geo/wgs84_pos# i.e. the namespace URI, not the prefix

15 UFIEKG-20-2 / 06 / Week 1315 Exercise BBC weather via RSS –Simple PHP coding exercise to transform the BBC feed to a format for the Foyer monitor Problems –How to include domain-specific data such as temperature, location –How to use the same server script to create a desktop, monitor and printed display

16 UFIEKG-20-2 / 06 / Week 1316 Next week Lecture –XPath provides allows complex selection of elements –XSLT is an XML transformation language Exercise –The geo namespace elements provide data on the location of the weather. –Locations are defined as a latitude value + a longitude value. –We can use this data to create place marks in Google Earth by transforming to kml (Keyhole Markup Language)


Download ppt "UFIEKG-20-2 / 06 / Week 131 Data, Schemas and Applications Term 2 Week 13."

Similar presentations


Ads by Google