XML Workshop XSLT
XML Tagged data Hello A really interesting course, well taught Interchange of data RSS, BPEL4WS, RossettaNet … Structure document representation Module specifications Languages XSLT, XSchema, Soap
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
Example – Family History Photo Id : integer 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 subject
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 2 B/W photograph Family sitting round the fireplace Robin Wallace Kenneth Wallace 12 Francis Wallace Cat Miss Whitfield Claremont, Brows Lane, Formby
Example – Events Person Event Name: string Date : date Birth DeathMarriage child father mother New Brighton Francis Wallace Kenneth Wallace Ida Wallace
xquery version "1.0"; (: List events for a person :) declare namespace request=" declare namespace 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
XSLT Event List Matches the top- level Document Apply matching templates in the given node-set Evaluate an expression and insert the result Elements written directly to the result
XSLT … : Born :Father, Mother Child Mother Match the node named eventList XPath Filter conditions,
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. Set context to the node matched. Apply this recursively
XSLT language Multilingual Output Imperative Control structures Procedural programming Rule-based matching Functional XPath Functions Process Control Debugging
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
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 –
Two programming styles Pull – structured programming (imperative) –XSL models output structure and pulls parts of the XML input into the output” Push –rule-based programming (declarative) –“XML is pushed through a set of matching rules” XML output XML output
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 –
Procedural programming Procedure call - –.. Call Parameters – Procedure definition –.. Procedure parameters –
Rule-based matching Template definition – Template application – Recursive Apply most specific template to a node –only one rule can match
Functional variables can be defined but they are constants Variable declaration – Variable value –
XPath Functions Boolean Functions String functions Numeric Functions Node sequence functions
Modular Programming Inclusion of another stylesheet – Inclusion of tempates from a stylesheet –
Process control Stylesheet declaration – Output control – Serialisation – Key – Define attributes –
Debugging Output Debug message –