Some Notes on XSLT Eugenia Fernandez IUPUI
Transforming XML with XSLT XSLT processor converts XML document into a node tree Uses XSLT stylesheet for instructions on what to do with these nodes Instructions are contained in templates
XSLT Templates Templates have two parts a node set selection (written in XPath) that identifies which nodes the template should be applied to instructions on the actual transformation i.e. what output is desired
Starting the Transformation The XSLT processor automatically looks for a root template which is applied to the root node The root template generally contains both literals that are output as is, and other XSLT templates that further process source nodes
Applying Templates instruction identifies a set of nodes and specifies that the nodes be processed at that point with the matching template can include other xsl:apply-templates This allows you to control the order in which the contents of the source document are processed and output.
Applying Templates: Push Document root ID My name is “Joe” My name is Joe
Applying Templates: Pull Document root ID Employee Name: “Joe” Employee Name: Joe ID “Joe”
Push Example: books2.xsl Book List,, $
Pull Example: books1.xsl, $
Push and Pull: books3.xsl Book List Book List by Title …
Sources Castro, E. (2001) XML for the World Wide Web, Berkeley, CA:PeachPit Press. “Practical Transformation using XSLT and Xpath”, G. Ken Holman, presentation at XML One Conference, Chicago, IL, May, 2001.