



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This document from the university of san francisco's department of computer science introduces xslt, an xml-based language for transforming documents. Xslt allows users to specify output for particular elements and is useful for emitting html, converting tag vocabularies, extracting plain text, and modifying xml documents. Various aspects of xslt, including output formats, filtering elements, emitting html and xml, copying nodes, and incorporating css.
Typology: Lab Reports
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Department of Computer ScienceUniversity of San Francisco
Department of Computer Science — University of San Francisco – p. 1/
??
specify how a document should be changed or transformed.^ ◦^ You specify the output for a particular element; no need tomanage tree traversal. • Useful for:^ ◦^ Emitting an HTML display of an XML document^ ◦^ Converting between tag vocabularies^ ◦^ Extracting plain text from an XML document^ ◦^ AUtomatically modifying or filtering an XML document.
Department of Computer Science — University of San Francisco – p. 2/
??
Plain text ◦ HTML ◦ XML (or any flavor thereof)
Department of Computer Science — University of San Fra
Tomorrow
Never^ Knows
Beatles
Revolver
Rock^
5
2:57^
6 ^ Feb^ ^2005 ...
Department of Computer Science — University of San Francisco – p. 4/
??
/usr/bin/4xslt on lab machines ◦ Most modern browsers have XSLT support ◦ Debugging is easier from the command line
Department of Computer Science — University of San Francisco – p. 5/
??
Department of Computer Science — University of San Fra
Department of Computer Science — University of San Francisco – p. 7/
??
Department of Computer Science — University of San Francisco – p. 8/
??
Useful if you want to change a bunch of values or attributes. • copy-of makes a deep copy and lets you specify a path. • For example, let’s make a new database with just artist, albumand title.
Department of Computer Science — University of San Fra
Department of Computer Science — University of San Francisco – p. 10/
??
processing
instruction
into the output document.
-^ Note: this will work best if we do the XSLT on the server side.^
href="songs.css"
type="text/css"
Department of Computer Science — University of San Francisco – p. 11/
??
More advanced features are not universally supported. ◦ In particular, the browser’s XSLT processor may make asingle pass and not apply the CSS. (firefox)
Department of Computer Science — University of San Fran
Department of Computer Science — University of San Francisco – p. 19/
??
Department of Computer Science — University of San Francisco – p. 20/
??
Department of Computer Science — University of San Fran
Department of Computer Science — University of San Francisco – p. 22/
??
...
Department of Computer Science — University of San Francisco – p. 23/
??
import^
Processor
from^ Ft.Xml
import
InputSource xsltproc
=^ Processor(
)
sweaterdata
= InputSource.DefaultFactory.fromUri(’sweater.xml’) sweaterxsl
=^ InputSource.DefaultFactory.fromUri(’sweater.xsl’) xsltproc.appendStylesheet(sweaterxsl)sweaterXML
=^ xsltproc.run(sweaterdata) print^ sweaterXML
Department of Computer Science — University of San Fran
Can emit text or XML • XPath allows you to easily identify nodes. • Makes it easy to have separate representations for storage ornetwor transmission and for display.
Department of Computer Science — University of San Francisco – p. 25/
??