2010-04-14 - Jakarta Taglibs has been retired.

For more information, please explore the Attic.

Jakarta Project: Simple XSL Tag Library

Version: 1.0.1

Table of Contents

Overview

A simple tag library for transforming XML input sources with XSL stylesheets

This tag library uses version 1 of both the Xerces XML parser and the Xalan XSLT processor. For production use we recommend you use the XTAGS tag library or the Standard tag library. Both of these use TRAX API compatible XSLT processors such as Xalan 2 and have more features.

Requirements

This custom tag library requires a servlet container that supports the JavaServer Pages Specification, version 1.1.

This custom tag library also requires the Xerces 1 XML parser and the Xalan 1 XSLT processor.

Configuration

Follow these steps to configure your web application with this tag library:

To use the tags from this library in your JSP pages, add the following directive at the top of each page:

<%@ taglib uri="http://jakarta.apache.org/taglibs/xsl-1.0" prefix="xsl" %>

where "xsl" is the tag name prefix you wish to use for tags from this library. You can change this value to any prefix you like.

Tag Summary

XSL Tags
applyApply an XSL transformation on an XML source
exportExport the content of a JSP Bean to the output.
importImport the contents of the specified page and store it as a String in the specified bean and scope.
includeInclude the contents of the specified page.
ShowSourceConvenience tag to show JSP Source.
 

Tag Reference

apply Availability: 1.0

Apply the specified stylesheet to the specified XML input, both of which may be acquired in a variety of manners depending upon the optional attributes that are included.

Tag BodyJSP    
Restrictions

Valid attribute combinations to select the XML data source are:

  • nameXml - The named bean defines the data source.
  • nameXml and propertyXml - The named property of the named bean defines the data source.
  • xml - The named resource is read (with getResourceAsStream()) to provide the data source.
  • (none) - The body of this tag is interpreted as the XML data source.
Valid attribute combinations to select the XSL stylesheet source are:
  • nameXsl - The named bean defines the stylesheet source.
  • nameXsl and propertyXsl - The named property of the named bean defines the data source.
  • xsl - The named resource is read (with getResourceAsStream()) to provide the data source.

AttributesNameRequired Runtime Expression Evaluation Availability
 nameXml  No   No  1.0
 

Name of a bean (in any scope) that defines the source of the XML data to be transformed. This bean must be of one of the following Java classes:

  • String (containing the XML data itself)
  • InputSource (SAX input source containing the data)
  • InputStream (byte stream containing the data)
  • Node (DOM tree containing the data
  • Reader (character stream containing the data)
  • XSLTInputSource (from which the data is read)

 nameXsl  No   No  1.0
 

Name of a bean (in any scope) that defines the source of the XSL stylesheet to be used. This bean must be of one of the following Java classes:

  • String (containing the stylesheet itself)
  • InputSource (SAX input source containing the stylesheet)
  • InputStream (byte stream containing the stylesheet)
  • Node (DOM tree containing the stylesheet)
  • Reader (character stream containing the stylesheet)
  • XSLTInputSource (from which the stylesheet is read)

 propertyXml  No   No  1.0
 

If specified, the bean identified by "nameXml" is assumed to have a property whose getter method is called to define the XML data source, instead of interpreting that bean itself.

 propertyXsl  No   No  1.0
 

If specified, the bean identified by "nameXsl" is assumed to have a property whose getter method is called to define the XSL stylesheet source, instead of interpreting that bean itself

 xml  No   Yes  1.0
 

If specified, the context-relative path to an application resource containing the XML data.

 xsl  No   Yes  1.0
 

If specified, the context-relative path to an application resource containing the XSL stylesheet.

VariablesNone
ExamplesNone
export Availability: 1.0

Export the contents of the specified JSP bean in the specified scope to our output stream, presumably after its contents have been manipulated.

Tag Bodyempty    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  Yes   No  1.0
 

Name of a JSP bean whose content is to be rendered to our output stream.

 scope  No   No  1.0
 

Scope in which this bean is registered. If not specified, page scope is assumed.

VariablesNone
ExamplesNone
import Availability: 1.0

Import the contents of the specified page, and store it as a String in the specified bean and scope. This tag is useful for assigning the content of XML data (or an XSL stylesheet) to a bean that can later be manipulated with the "apply" tag.

Tag Bodyempty    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 id  Yes   No  1.0
 

Name of a JSP bean to be created containing the contents of the specified page as a String.

 page  Yes   Yes  1.0
 

Context-relative URI of the page (or servlet) to be executed, and whose output should be imported

 scope  No   No  1.0
 

Scope in which the bean specified by "id" will be created (page, request, session, application). If not specified, page scope is assumed.

VariablesNone
ExamplesNone
include Availability: 1.0

Include the contents of the specified page. This tag is similar to <jsp:include>, but causes the included contents to be rendered to our JspWriter (and thus to the body content of any enclosing tag) rather than being sent directly to the output stream.

Tag Bodyempty    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 page  Yes   Yes  1.0
 

Context-relative URI of the page (or servlet) to be executed, and whose output should be included at this point.

VariablesNone
ExamplesNone
ShowSource Availability: 1.0

Convenience tag to show JSP Source.

Tag Bodyempty    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 jspFile  Yes   Yes  1.0
 

Web application context relative JSP file to show source for.

VariablesNone
ExamplesNone

Examples

See the example application xsl-examples.war for examples of the usage of the tags from this custom tag library.

Java Docs

Java programmers can view the java class documentation for this tag library as javadocs.

Revision History

Review the complete revision history of this tag library.