com.arsdigita.templating
Class XSLTemplate

java.lang.Object
  extended bycom.arsdigita.templating.XSLTemplate

public final class XSLTemplate
extends Object

A class for loading, caching and generally managing XSL templates and transformers.

Version:
$Id: //core-platform/dev/src/com/arsdigita/templating/XSLTemplate.java#14 $
Author:
Dan Berrange

Field Summary
static String versionId
           
 
Constructor Summary
XSLTemplate(URL source)
          Creates and loads a new template from source using the default ErrorListener.
XSLTemplate(URL source, javax.xml.transform.ErrorListener listener)
          Creates and loads a new template from source, using listener to handle any errors.
 
Method Summary
 List getDependents()
          Gets a list of all dependent stylesheet files.
 URL getSource()
          Gets the URL of the template source.
 boolean isModified()
          Checks whether the XSL files associated with the template have been modified.
 javax.xml.transform.Transformer newTransformer()
          Generates a new Transformer from the internal Templates object.
 void toZIP(OutputStream os, String base)
          Creates a ZIP file containing this stylesheet and all dependant's.
 void transform(org.w3c.dom.Document doc, PrintWriter writer)
          Transforms doc and streams the result to writer.
 void transform(org.w3c.dom.Document doc, PrintWriter writer, javax.xml.transform.ErrorListener listener)
          Transforms doc and streams the result to writer.
 void transform(javax.xml.transform.Source source, javax.xml.transform.Result result)
          Transforms the source document and sends it to result.
 void transform(javax.xml.transform.Source source, javax.xml.transform.Result result, javax.xml.transform.ErrorListener listener)
          Transforms the source document and sends it to result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

XSLTemplate

public XSLTemplate(URL source,
                   javax.xml.transform.ErrorListener listener)
Creates and loads a new template from source, using listener to handle any errors.

Parameters:
source - A URL pointing to the template source text
listener - A ErrorListener to customize behavior on error

XSLTemplate

public XSLTemplate(URL source)
Creates and loads a new template from source using the default ErrorListener.

Parameters:
source - A URL pointing to the template source text
Method Detail

getSource

public final URL getSource()
Gets the URL of the template source.

Returns:
The URL location of the template source; it cannot be null

getDependents

public final List getDependents()
Gets a list of all dependent stylesheet files.

Returns:
A List of URLs to dependent stylesheet files; it cannot be null

newTransformer

public final javax.xml.transform.Transformer newTransformer()
Generates a new Transformer from the internal Templates object.

Returns:
The new Transformer; it cannot be null

transform

public final void transform(javax.xml.transform.Source source,
                            javax.xml.transform.Result result,
                            javax.xml.transform.ErrorListener listener)
Transforms the source document and sends it to result. If there are errors, listener handles them. This method internally creates and uses a new Transformer.

Parameters:
source - The Source to be transformed; it cannot be null
result - The Result to capture the transformed product; it cannot be null
listener - A ErrorListener to handle transformation errors; it cannot be null

transform

public final void transform(javax.xml.transform.Source source,
                            javax.xml.transform.Result result)
Transforms the source document and sends it to result. This method internally creates and uses a new Transformer.

Parameters:
source - The Source to be transformed; it cannot be null
result - The Result to capture the transformed product; it cannot be null

transform

public final void transform(org.w3c.dom.Document doc,
                            PrintWriter writer,
                            javax.xml.transform.ErrorListener listener)
Transforms doc and streams the result to writer. If there are errors, listener handles them.

Parameters:
doc - The Document to transform; it cannot be null
writer - The PrintWriter to receive the transformed result; it cannot be null
listener - A ErrorListener to handle any errors; it cannot be null

transform

public final void transform(org.w3c.dom.Document doc,
                            PrintWriter writer)
Transforms doc and streams the result to writer.

Parameters:
doc - The Document to transform; it cannot be null
writer - The PrintWriter to receive the transformed result; it cannot be null

isModified

public final boolean isModified()
Checks whether the XSL files associated with the template have been modified.

Returns:
true if any dependent files have been modified, otherwise false

toZIP

public void toZIP(OutputStream os,
                  String base)
           throws IOException
Creates a ZIP file containing this stylesheet and all dependant's. NB, this method assumes that all stylesheets live in the same URL protocol. If the protocol a file is different from the protocol of the top level, then this file will be excluded from the ZIP. In practice this limitation is not critical, because XSL files should always use relative imports, which implies all imported files will be in the same URL space.

Parameters:
os - the output stream to write the ZIP to
base - the base directory in which the files will extract
Throws:
IOException


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC