Presentation is loading. Please wait.

Presentation is loading. Please wait.

XSLT & XPATH. From Friday Everything in XML is machine readable Attributes describe elements, so does an element’s place in the tree (context) XML must.

Similar presentations


Presentation on theme: "XSLT & XPATH. From Friday Everything in XML is machine readable Attributes describe elements, so does an element’s place in the tree (context) XML must."— Presentation transcript:

1 XSLT & XPATH

2 From Friday Everything in XML is machine readable Attributes describe elements, so does an element’s place in the tree (context) XML must be – Well formed (following XML syntax rules) – Valid (following the rules of the specified DTD[s])

3 Your resume should look like:

4 Question How can copyright & attribution information be maintained in mashups?

5 Using Meta Data in Decisions Or Why bother with structured markup? facilitate (re)usability by others

6 Image an Article: body creator Title Featured image?

7 HTML

8 RDFa Resource Description Framework in [xhtml] attributes

9 Down Stream Uses of Structure Currently, FB guesses at what the ‘featured’ image might be when you Post a link. Wouldn’t it be better if tumblr told FB?

10 Down Stream Uses of Structure

11 Provenance Provenance :: where something came from … wouldn’t be nice if tumblr style provenance Was inter-system

12 Question How can copyright & attribution information be maintained in mashups?

13 XSLT & XPATH XPATH = XML query language XSLT = Translate XML from one schema to another – Extensible Stylesheet Language Transformations XSLT is nothing without XPATH

14 XPATH XSLT CSS (sorta) jQuery (sorta) PHP SimpleXML

15 Get an RSS File Example: nytimes.com Click on RSS button – (see the rss being transformed into HTML by the browser) View Source

16 XPATH Selectors // selects the root element channel selects the channel element and all of its children //channel/title / moves down the tree and selects the title element

17 XPATH Selectors title/.. selects channel /. selects the current element (if you're in a loop or something)

18 XPATH Selectors (attributes) @ selects nodes attributes channel/link/@type selects the type attribute in link

19 XPATH Conditionals go in [] //channel/item[1] selects the first item [last()] [position()<15] //a[@href="http://www.rpi.edu"]

20 XPATH Operators & Comparators + - * div = >= <= or and mod | is not OR it is used to concatenate sets of elements

21 XPATH functions position() last() abs() floor() string-length() name() http://www.w3.org/TR/xpath-functions/ http://www.w3schools.com/Xpath/xpath_functio ns.asp http://www.w3schools.com/Xpath/xpath_functio ns.asp

22 XPATH Get, run, files from: – http://www.rpi.edu/~gillw3/websys/xslt/files/ http://www.rpi.edu/~gillw3/websys/xslt/files/ (inspect both, open the RSS file in your browser)

23 XSLT XSL is XML Transforms XML into XML We'll transform XML into XHTML

24 XSLT Where does XSLT happen? – server side: http://us2.php.net/manual/en/book.xsl.php – Client side: FF / Safari / IE add to the top of your xml document

25 XSLT Use XPATH to select (and display) element values XSLT value-of

26 XSLT Control Structures If Choose / when / otherwise for-each sort templates

27 XSLT if

28 XSLT Choose output output May stack many tests / conditions

29 XSLT for-each

30 XSLT Sort Datatype & order attributes: http://www.xml.com/pub/a/2002/07/03/transform.html

31 XSLT Templates Template is a container for a chunk of XSLT XPATH inside of the template starts where the match attribute ends stuff: output & control

32 XSLT Templates Templates As Functions value

33 In Class Grab this XML feed: http://events.rpi.edu/webcache/v1.0/xmlDays /3/list-xml/no--filter.xml http://events.rpi.edu/webcache/v1.0/xmlDays /3/list-xml/no--filter.xml Using XPATH and XSLT: – Print out a list of events from the feed – Put the summary in an – Put the description in a – Include a human readable start time & date


Download ppt "XSLT & XPATH. From Friday Everything in XML is machine readable Attributes describe elements, so does an element’s place in the tree (context) XML must."

Similar presentations


Ads by Google