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 be – Well formed (following XML syntax rules) – Valid (following the rules of the specified DTD[s])
Your resume should look like:
Question How can copyright & attribution information be maintained in mashups?
Using Meta Data in Decisions Or Why bother with structured markup? facilitate (re)usability by others
Image an Article: body creator Title Featured image?
HTML
RDFa Resource Description Framework in [xhtml] attributes
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?
Down Stream Uses of Structure
Provenance Provenance :: where something came from … wouldn’t be nice if tumblr style provenance Was inter-system
Question How can copyright & attribution information be maintained in mashups?
XSLT & XPATH XPATH = XML query language XSLT = Translate XML from one schema to another – Extensible Stylesheet Language Transformations XSLT is nothing without XPATH
XPATH XSLT CSS (sorta) jQuery (sorta) PHP SimpleXML
Get an RSS File Example: nytimes.com Click on RSS button – (see the rss being transformed into HTML by the browser) View Source
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
XPATH Selectors title/.. selects channel /. selects the current element (if you're in a loop or something)
XPATH Selectors selects nodes attributes selects the type attribute in link
XPATH Conditionals go in [] //channel/item[1] selects the first item [last()] [position()<15]
XPATH Operators & Comparators + - * div = >= <= or and mod | is not OR it is used to concatenate sets of elements
XPATH functions position() last() abs() floor() string-length() name() ns.asp ns.asp
XPATH Get, run, files from: – (inspect both, open the RSS file in your browser)
XSLT XSL is XML Transforms XML into XML We'll transform XML into XHTML
XSLT Where does XSLT happen? – server side: – Client side: FF / Safari / IE add to the top of your xml document
XSLT Use XPATH to select (and display) element values XSLT value-of
XSLT Control Structures If Choose / when / otherwise for-each sort templates
XSLT if
XSLT Choose output output May stack many tests / conditions
XSLT for-each
XSLT Sort Datatype & order attributes:
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
XSLT Templates Templates As Functions value
In Class Grab this XML feed: /3/list-xml/no--filter.xml /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