XSLT is a template-driven environment for defining transformations between one XML document format and another. An XSLT stylesheet contains template rules that are matched against nodes in the input document. When a match is detected, the rule’s template is instantiated and the result added to the result tree. XSLT is itself an XML application that contains numerous elements for specifying exactly which nodes are matched when and what output is generated as a result.
XSLT is also a Turing-complete, functional programming language. Templates can be called by name, and can be called recursively. Parameters can be passed to templates. XSLT is not as convenient to program in as traditional languages like Java, but in its problem domain this approach works extremely well.
TrAX is a standard API for XSLT processors that is part of Java 1.4 and later and is bundled with most current XSLT processors for Java including Saxon, Xalan, and jd.xslt. TrAX follows the abstract factory design pattern. A TransformerFactory object creates Transformer objects from stylesheets. The Transformer objects transform XML documents in a variety of representations according to the instructions in their stylesheets. Both XSLT stylesheets and input XML documents are initially wrapped by a Source object. The target for output is wrapped by a Result object. TrAX includes a number of standard source and result implementations for different models including SAX, DOM, and streams.
As well as integrating XSLT into your Java programs, you can integrate Java into your XSLT stylesheets through extension elements and functions. The extension-element-prefixes attribute specifies which namespace prefixes are mapped to extension elements. The namespace URIs are used to find the necessary .class files in the processor’s class path. The element-available() and function-available() functions and the xsl:fallback element test for the presence of extension functions and elements so you can write portable stylesheets that work with or without the extensions. Once you’ve set this up, you can use the extension elements and functions just like standard XSLT elements and functions.
|Copyright 2001, 2002 Elliotte Rusty Haroldfirstname.lastname@example.org||Last Modified June 04, 2002|
|Up To Cafe con Leche|