Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multi Platform Applications XML, XPath, XSLT transform.

Similar presentations


Presentation on theme: "Multi Platform Applications XML, XPath, XSLT transform."— Presentation transcript:

1 Multi Platform Applications XML, XPath, XSLT transform

2 This Week XPATH – way of breaking down XML docs XML-FO – a method to format docs XSLT – A simpler method of formatting docs

3 XPATH Used to break down the structure of a XML doc and reference sections The nodes of an XML document can be treated as parts of a document tree

4 Nodes of an XML doc document (root) nodes comment,processing-instruction,namespace,text,attribute,element,

5 XML nodes <message><mail><to>Patrick</to><from>Mick</from><heading>Meeting</heading> Don't forget we need to meet tonight Don't forget we need to meet tonight </mail></message> Node

6 XML relationships - children <message><mail><to>Patrick</to><from>Mick</from><heading>Meeting</heading> Don't forget we need to meet tonight Don't forget we need to meet tonight </mail></message> Children of the message object

7 XML relationships – parent and siblings <message><mail><to>Patrick</to><from>Mick</from><heading>Meeting</heading> Don't forget we need to meet tonight Don't forget we need to meet tonight </mail></message> Parent of the to,from, heading etc objects These four items are siblings (same parent)

8 XML relationships - ancestors <message><mail><to>Patrick</to><from>Mick</from><heading>Meeting</heading> Don't forget we need to meet tonight Don't forget we need to meet tonight </mail></message> Ancestors of the “to” object are the mail and message object

9 XML relationships - descendants <message><mail><to>Patrick</to><from>Mick</from><heading>Meeting</heading> Don't forget we need to meet tonight Don't forget we need to meet tonight </mail></message> Al these are descendants of the message object

10 XPath Methods of selecting nodes

11 Selecting Nodes ExpressionDescription nodename Selects all child nodes of the named node / Selects from the root node // Selects nodes in the document that matches the named node in the document. Selects the current node.. Selects the parent of the current node @ Selects attributes

12 XPath addressing For example to – will highlight all items called to /message – will select all items under that element //body – will select all items in the document of that name

13 Expressions Path ExpressionResult /mail/subject[1]Selects the first subject element that is the child of the mail element /mail/subject[last()]Selects the last subject element that is the child of the mail element /mail/subject[last()-1]Selects the last but one subject element that is the child of the mail element /mail/subject[position()<3]Selects the first two subject elements that are children of the mail element /mail/subject[ID>5]Selects all the subject elements of the mail element that have a ID element with a value greater than 35.00 /mail/subject[ID>5]/priorit y Selects all the title elements of the subject elements of the mail element that have an ID element with a value greater than 5

14 Wildcards * - Matches any element node * - Matches any element node @* - Matches any attribute node @* - Matches any attribute node node() -- Matches any node of any kind node() -- Matches any node of any kind

15 Further Reading Look into Xpath Axes and Xpath Location paths You can also see the operators available at http://www.w3.org/TR/2005/WD-xpath- functions-20050404/#op.numeric http://www.w3.org/TR/2005/WD-xpath- functions-20050404/#op.numeric http://www.w3.org/TR/2005/WD-xpath- functions-20050404/#op.numeric Or http://www.w3schools.com/xpath/xpath_fu nctions.asp http://www.w3schools.com/xpath/xpath_fu nctions.asp http://www.w3schools.com/xpath/xpath_fu nctions.asp

16 XLink and Xpointer XLink - XML Linking Language XLink is a language for creating hyperlinks in XML documents XLink is similar to HTML links - but more powerful Not limited to images and text - any element in an XML document can behave as an XLink

17 Xlinks 2 XLink has two grouping of links simple links (like HTML) and extended links (for linking multiple resources) With XLink, the links can be defined externally to the linked resources XLink is a W3C Standard

18 XPointer XPointer - XML Pointer Language XPointer allows hyperlinking to specific parts of an XML document XPointer uses XPath expressions to navigate the position in an XML document XPointer is a W3C Standard

19 Simple Xlink Visit Bolton Visit Bolton BBC BBC </homepages>

20 Pointing with Paths Remember the CD catalog example How would we pick out an artist from that XML file? We can point not just to a file but to an area of a file e.g. href="http://www.bolton.ac.uk/catalog.xml#di sc(‘Hits').child(1,item)"

21 XML <collection> Five Five UK UK Telstar Telstar 4.99 4.99 2003 2003..</collection>

22 Xpointer and links xlink:href="http://www.bolton.ac.uk/catal og.xml#xpointer(id(‘Hits'))" You can use a shorter version when linking to an element with an id tag. You can use the value of the id directly, like this: http://www.bolton.ac.uk/catalog.xml#Hit s"

23 Useful Links http--www.topxml.com-tutorials-sqlxml- sqlxml.pdf http--www.topxml.com-tutorials-sqlxml- sqlxml.pdf SQL Server 2000 and XML Part 6 - Annotated XDR Schemes Free Tutorial Beginners.co.uk SQL Server 2000 and XML Part 6 - Annotated XDR Schemes Free Tutorial Beginners.co.uk


Download ppt "Multi Platform Applications XML, XPath, XSLT transform."

Similar presentations


Ads by Google