Transforming XML Part I - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

Transforming XML Part I

Description:

Transforming XML Part I Document Navigation with XPath John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: 0131 551 8073 (x2073) – PowerPoint PPT presentation

Number of Views:111
Avg rating:3.0/5.0
Slides: 26
Provided by: JohnAr156
Category:
Tags: xml | part | transforming

less

Transcript and Presenter's Notes

Title: Transforming XML Part I


1
Transforming XML Part I
  • Document Navigation with XPath

John Arnett, MSc Standards Modeller Information
and Statistics Division NHSScotland Tel 0131 551
8073 (x2073) mailtoJohn.Arnett_at_isd.csa.scot.nhs.u
k http//isdscotland.org/xml
2
Contents
  • Document Processing
  • Nodes and Trees
  • XPath Locating Nodes
  • Summary
  • Find Out More

3
Document Processing
  • The XSL Family
  • XPath (XML Path Language)
  • XSLT (Extensible Stylesheet Language
    Transformations)
  • XSL aka XSL-FO (Extensible Stylesheet Language
    Formatting Objects)

4
Document Processing
  • XPath
  • Used to locate specific parts of an XML source
    document efficiently and effectively
  • XPath v1.0 W3C Recommendation

5
Document Processing
  • XSLT
  • Used to transform XML documents to another XML or
    non-XML form esp. HTML
  • XSLT v1.0 W3C Recommendation
  • v2.0 W3C Working Draft
  • Uses XPath for locating document content

6
Document Processing
  • XSL(-FO)
  • Used to format XML documents into fixed sized
    folios for publication
  • XSL v1.0 W3C Recommendation
  • Uses XSLT for document transformation

7
Document Processing
  • Transformation and formatting
  • XPath used to locate nodes for input
  • XSLT used to transform input and generate result
    tree
  • XSL-FO used to format output document

8
Document Processing
Source Tree
Stylesheet Processor
Formatted Output
Result Tree
Format
Transform
Style sheet
Adapted from XSLT Basics slide presentation by
Paul Spencer, alphaXML
9
Trees and Nodes
  • XML document is viewed as a source tree
    containing different node types
  • root
  • element
  • text
  • attribute
  • namespace
  • processing instruction
  • comment

10
Trees and Nodes
  • XML Appointment example

lt!-- radiology appointment --gt ltAppointment
deptCodeRADIOgt ltPatient upiABC-123-456gtJoh
n Smith ltPhoneNogt0141 662 2673lt/PhoneNogt
lt/Patientgt ltCliniciangtAlison
Younglt/Cliniciangt ltSlot attendDate2003-08-05gt
ltStartTimegt143000lt/StartTimegt lt/Slotgt
lt/Appointmentgt
11
Trees and Nodes
  • XPath view of Appointment source tree

12
XPath Locating Nodes
  • XPath expressions (location paths)
  • Used to navigate source tree and locate nodes for
    input
  • Comprised of one or more location steps
  • axis node test (optional) predicate
  • May contain functions, e.g.
  • position(), count(node-set), last()

13
XPath Locating Nodes
  • Axes
  • Specify node locations relative to the current
    (context) node self
  • May traverse tree forwards or backwards

14
XPath Locating Nodes
  • Axes for forward traversal
  • child
  • attribute
  • descendant-or-self
  • descendant
  • following
  • following-sibling
  • namespace

15
XPath Locating Nodes
  • Axes for reverse traversal
  • parent
  • ancestor
  • ancestor-or-self
  • preceding
  • preceding-sibling

16
XPath Locating Nodes
  • Node Tests
  • Refine node set selection
  • select all nodes of same type
  • node() select all nodes of any type
  • Select all nodes of type text(), comment() or
    processing-instruction()
  • Select all nodes with specified name

17
XPath Locating Nodes
  • Select Clinician element node
  • childAppointment/childClinician or
  • Appointment/Clinician

18
XPath Locating Nodes
  • Select upi attribute node
  • childPatient/attributeupi or
  • Patient/_at_upi

19
XPath Locating Nodes
  • Select all descendant text nodes
  • /descendant-or-selfnode()/childtext() or
  • //text()

20
XPath Locating Nodes
  • Select parent of StartTime element
  • parentnode() or ..

21
XPath Locating Nodes
  • Using wildcards
  • child or

22
XPath Locating Nodes
  • Abbreviating location steps
  • child and text() can usually be omitted

childAppointment/childClinician/childtext()
Appointment/Clinician
  • attribute _at_
  • Patient/_at_upi
  • self()node .
  • parentnode() ..

23
XPath Locating Nodes
  • Abbreviating Location Paths
  • /descendant-or-selfnode()/ //
  • /descendant-or-selfnode()/childtext()
    //text()

24
In Summary
  • XML document processing
  • XPath - node location
  • XSLT - transformation
  • XSL-(FO) - document formatting
  • XPath used to navigate source tree
  • Transformation performed by applying style sheet
    to source document

25
Find Out More
  • The Extensible Stylesheet Language Family (XSL)
  • www.w3.org/Style/XSL/
  • W3C XML Path Language v1.0 Specification
  • www.w3.org/TR/xpath
  • TopXML XSLT XPath Tutorial
  • www.vbxml.com/xsl/tutorials/intro/default.asp
Write a Comment
User Comments (0)
About PowerShow.com