Download presentation
Presentation is loading. Please wait.
1
XSLT XML DBs, and Schemas Week 18 DSA
2
The Whisky Case study XSLT can be applied in the client. –Add a xml processing instruction to the xml to bind to a XSLT script –http://www.cems.uwe.ac.uk/~cjwallac/apps/sc otch/http://www.cems.uwe.ac.uk/~cjwallac/apps/sc otch/ –See listings of Distillery xml with link to stylesheet Stylesheet with link to CSS CSS stylesheet
3
<!-- This stylesheet selects some elements from the whisky XML data, formats for display using classes. Only some tags are included - the remaining data is ignored. Connection with the css stylesheet is via class tags. Note these classes should be documented --> Whiskies of Scotland Whiskys of Scotland Matches the top- level Document Elements written directly to the result Apply matching templates in the given element sequence – all children here
4
Match the element named Distillery Evaluate an expression and insert the result Here just the text in the current element
5
XSLT process XML document XSLT document XSLT process XML or plain text parameters Parse inputs, set context to root; While nodes in context, for each node, check if any templates match – choose the most specific and apply the template Apply this recursively
6
An XML case study A combination of a photo album and a family history http://www.cems.uwe.ac.uk/chriswallace/in dex.xqlhttp://www.cems.uwe.ac.uk/chriswallace/in dex.xql
7
XML – a sample system eXist Native XML Database XQuery process Java Stores XML, XQuery,XSL CSS and binary files (JPEG) XSLT process CSS process Server Client Browser
8
Example – Family History Photo Image: jpeg Description: string Date: date Media: string Inscription: string Person Event Name: string Date : date age Place Address : string Lat: decimal Long: decimal BirthDeathMarriage
9
Many-many resolution in XML Photo Image: jpeg Description: string Date: date Media: string Inscription: string (Subject: ( Person: name Age: integer) | Animal : name )* Place: (address, lat, log) | name B/W photograph Family sitting round the fireplace Robin Wallace Kenneth Wallace 12 Francis Wallace Cat Miss Whitfield Claremont, Brows Lane, Formby -3.06608 53.55555
10
Example – Events Person Event Name: string Date : date Birth DeathMarriage child father mother Birth Francis Wallace 1911-04-26 Kenneth Wallace Ida Wallace New Brighton
11
xquery version "1.0"; (: List events for a person :) declare namespace request="http://exist-db.org/xquery/request"; declare namespace transform = "http://exist-db.org/xquery/transform"; let $person := request:request-parameter('person',''), (: get the set of events in which this person is involved :) $events := document(/'db/history/events.xml')/eventList/event[.//person = $person], (: get the stylesheet :) $ss := document('/db/history/eventList.xsl'), (: set the 'focus' of the event list to the person :) $params :=, (: order the events in ascending date order :) $elist := {for $e in $events order by $e/date return $e } return (: return the event list transformed by the stylesheet :) transform:transform($elist,$ss,$params) XQuery
12
XSLT Event List Evaluate an expression and insert the result
13
XSLT … : Born at Father, Mother : Child born at Mother XPath Filter conditions, implicitly anded
14
XSLT language Multilingual Output Imperative Control structures Procedural programming Template matching Functional XPath Functions Process Control Debugging
15
Multi-lingual Plain text and plain xml xsl (identified by the xsl:namespace) XPath to define node-sets Filter conditions to select subsets XPath functions to manipulate the nodes Comments –
16
Result output Insert evaluated expression Insert plain text – …. Insert processing instruction – Insert a number – like a level number – Copy nodes into the output – Create a node –
17
Imperative Control Structures Imperative Control structures –Sequence of data and instructions –Selection One option – Multiple options – –Iteration Iterate over nodes in a sequence – Order nodes in the iteration –
18
Procedural programming Procedure call - –.. Call Parameters – Procedure definition –.. Procedure parameters –
19
Template matching Template definition – Template application – Recursive Apply most specific template to a node Declarative code a challenge to debug
20
Functional variables can be defined but they are constants –
21
XPath Functions Boolean Functions String functions Numeric Functions Node sequence functions
22
Modular Programming Inclusion of another stylesheet – Inclusion of tempates from a stylesheet –
23
Process control Stylesheet declaration – Output control – Serialisation – Key – Define attributes –
24
Debugging Output Debug message –
25
XML Schema A definition of the structure of a class of XML documents. Uses –Check that a given document is a member of the class – ‘Validation’ –http://tools.decisionsoft.com/schemaValidate/http://tools.decisionsoft.com/schemaValidate/ –Determine the basic structure of a data entry form – InfoPath
26
XML Schema in action QSEE XML Schema XML document Validator analysis Form Builder (InfoPath) Form Definition Form engine (InfoPath) XML Document Generalise (Trang) XML Document
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.