| java.lang.Object org.jasig.portal.utils.XSLT
All known Subclasses: org.jasig.portal.i18n.LocaleAwareXSLT,
XSLT | public class XSLT (Code) | | This utility provides methods for transforming XML documents
via XSLT. It takes advantage of Xalan's ability to pre-compile
stylehseets into StylesheetRoot objects. The first time a transform
is requested, a stylesheet is compiled and cached.
None of the method signatures in this class should contain
classes specific to a particular XSLT engine, e.g. Xalan, or
XML parser, e.g. Xerces.
The constructor for XSLT takes an instance of whatever class is requesting
the transformation. XSLT uses this instance to locate resources relative
to the classpath.
Typical usage:
XSLT xslt = new XSLT(this);
xslt.setXML("myXMLDoc.xml");
xslt.setSSL("myChannel.ssl", "aTitle", runtimeData.getBrowserInfo());
xslt.setTarget(out);
xslt.setStylesheetParameter("param1Name", "param1Value");
xslt.setStylesheetParameter("param2Name", "param2Value");
xslt.transform();
author: Ken Weiner, kweiner@unicon.net version: $Revision: 42266 $ |
Constructor Summary | |
public | XSLT(Object instance) Constructs an XSLT object. |
Method Summary | |
protected static void | addLocalization(Document xsl, ResourceBundle localization) | protected static String | escape(String s) | public static SAXTransformerFactory | getSAXTFactory() | public static int | getStylesheetCacheSize() Get the number of stylesheets in the stylesheet root cache. | public static StylesheetSet | getStylesheetSet(String stylesheetListURI) This method caches compiled stylesheet set objects, keyed by the stylesheet list's URI. | public static String | getStylesheetURI(String sslUri, BrowserInfo browserInfo) Returns a stylesheet URI exactly as it appears in a stylesheet list file. | public static String | getStylesheetURI(String sslUri, String title, BrowserInfo browserInfo) Returns a stylesheet URI exactly as it appears in a stylesheet list file. | public static Templates | getTemplates(String stylesheetURI, ResourceBundle l18n) This method caches compiled stylesheet objects, keyed by the stylesheet's URI and locale. | public static Templates | getTemplates(String stylesheetURI) This method caches compiled stylesheet objects, keyed by the stylesheet's URI. | public static XSLT | getTransformer(Object instance) Factory method that produces an XSLT transformer utility. | public static XSLT | getTransformer(Object instance, Locale[] locales) Factory method that produces an XSLT transformer utility
with a capability of choosing a stylesheet depending on a
list of locales. | public static Transformer | getTransformer(String stylesheetURI, ResourceBundle l18n) This method returns a localized Transformer for a given stylesheet. | public static Transformer | getTransformer(String stylesheetURI) This method returns a Transformer for a given stylesheet. | public static TransformerHandler | getTransformerHandler(String stylesheetURI) This method returns a TransformerHandler for a given stylesheet. | public static TransformerHandler | getTransformerHandler(String stylesheetURI, Locale[] locales, Object caller) This method returns a localized TransformerHandler for a given stylesheet. | public static void | purgeStylesheetCache() Purge the cache of stylesheet roots and stylesheet sets. | public void | setResourceBundle(ResourceBundle bundle) | public void | setStylesheetParameter(String name, String value) Sets all the stylesheet parameters at once. | public void | setStylesheetParameters(Hashtable stylesheetParameters) Sets all the stylesheet parameters at once. | public void | setStylesheetParameters(HashMap stylesheetParameters) Sets all the stylesheet parameters at once. | public void | setTarget(ContentHandler contentHandler) Configures the xslt target. | public void | setTarget(java.io.OutputStream os) Configures the xslt target. | public void | setTarget(org.w3c.dom.Node node) Configures the xslt target. | public void | setXML(String xml) Configures the xml source. | public void | setXML(Node xml) Configures the xml source. | public void | setXML(java.io.InputStream is) Configures the xml source. | public void | setXML(java.io.File file) Configures the xml source. | public void | setXSL(String xslUri) Configures the xsl source. | public void | setXSL(String sslUri, String stylesheetTitle, BrowserInfo browserInfo) Configures the xsl source by choosing the appropriate stylesheet from
the provided stylesheet list file. | public void | setXSL(String sslUri, BrowserInfo browserInfo) Configures the xsl source by choosing the appropriate stylesheet from
the provided stylesheet list file. | public String | toString() | public void | transform() Performs a transformation. | public static void | transform(Source xmlSource, Result xmlResult, Hashtable stylesheetParams, String xslURI) Performs an XSL transformation. |
stylesheetRootCache | final protected static Hashtable stylesheetRootCache(Code) | | |
stylesheetRootCacheEnabled | protected static boolean stylesheetRootCacheEnabled(Code) | | |
stylesheetSetCache | final protected static Hashtable stylesheetSetCache(Code) | | |
stylesheetSetCacheEnabled | protected static boolean stylesheetSetCacheEnabled(Code) | | |
XSLT | public XSLT(Object instance)(Code) | | Constructs an XSLT object. This contructor should
be declared protected, but it will remain public for a while
until most client code is changed to use the getTransformer()
methods. Please avoid using this constructor!
Parameters: instance - the client of this utility |
addLocalization | protected static void addLocalization(Document xsl, ResourceBundle localization)(Code) | | Writes a set of key/value pairs from a resourcebundle as global variables
in an xsl stylesheet
Parameters: xsl - the xsl stylesheet as a DOM document Parameters: localization - the resource bundle of key/value pairs to be written to xsl variables |
escape | protected static String escape(String s)(Code) | | Escape problem characters which will be inserted into XSL
Parameters: s - the string to escape |
getStylesheetCacheSize | public static int getStylesheetCacheSize()(Code) | | Get the number of stylesheets in the stylesheet root cache.
the number of stylesheets in the stylesheet root cache. |
getStylesheetSet | public static StylesheetSet getStylesheetSet(String stylesheetListURI) throws PortalException(Code) | | This method caches compiled stylesheet set objects, keyed by the stylesheet list's URI.
Parameters: stylesheetListURI - the URI of the XSLT stylesheet list file (.ssl) the StlyesheetSet object throws: PortalException - |
getStylesheetURI | public static String getStylesheetURI(String sslUri, String title, BrowserInfo browserInfo) throws PortalException(Code) | | Returns a stylesheet URI exactly as it appears in a stylesheet list file.
Parameters: sslUri - the stylesheet list file URI Parameters: title - the stylesheet title Parameters: browserInfo - the browser information the stylesheet URI as a string throws: org.jasig.portal.PortalException - |
getTransformer | public static XSLT getTransformer(Object instance)(Code) | | Factory method that produces an XSLT transformer utility.
Parameters: instance - the client of this utility a transformer utility since: uPortal 2.2 |
getTransformer | public static XSLT getTransformer(Object instance, Locale[] locales)(Code) | | Factory method that produces an XSLT transformer utility
with a capability of choosing a stylesheet depending on a
list of locales.
Parameters: instance - the client of this utility a locale-aware transformer utility since: uPortal 2.2 |
getTransformerHandler | public static TransformerHandler getTransformerHandler(String stylesheetURI, Locale[] locales, Object caller) throws SAXException, PortalException(Code) | | This method returns a localized TransformerHandler for a given stylesheet.
Parameters: stylesheetURI - the URI of the XSLT stylesheet Parameters: locales - the list of locales Parameters: caller - the calling class Transformer throws: SAXException - |
purgeStylesheetCache | public static void purgeStylesheetCache()(Code) | | Purge the cache of stylesheet roots and stylesheet sets.
|
setStylesheetParameter | public void setStylesheetParameter(String name, String value)(Code) | | Sets all the stylesheet parameters at once.
Parameters: name - the name of the stylesheet parameter Parameters: value - the value of the stylesheet parameter |
setStylesheetParameters | public void setStylesheetParameters(Hashtable stylesheetParameters)(Code) | | Sets all the stylesheet parameters at once.
Parameters: stylesheetParameters - a Hashtable of stylesheet parameters |
setStylesheetParameters | public void setStylesheetParameters(HashMap stylesheetParameters)(Code) | | Sets all the stylesheet parameters at once.
Parameters: stylesheetParameters - a HashMap of stylesheet parameters |
setTarget | public void setTarget(ContentHandler contentHandler)(Code) | | Configures the xslt target.
Parameters: contentHandler - the content handler |
setTarget | public void setTarget(org.w3c.dom.Node node)(Code) | | Configures the xslt target.
Parameters: node - target node |
setXML | public void setXML(String xml)(Code) | | Configures the xml source.
Parameters: xml - a string representing the xml document |
setXML | public void setXML(Node xml)(Code) | | Configures the xml source.
Parameters: xml - a node representing the xml document |
setXML | public void setXML(java.io.InputStream is)(Code) | | Configures the xml source.
Parameters: is - an input stream to the serialized xml source |
setXML | public void setXML(java.io.File file)(Code) | | Configures the xml source.
Parameters: file - a File object representing the xml source |
setXSL | public void setXSL(String xslUri) throws PortalException(Code) | | Configures the xsl source.
Parameters: xslUri - the URL of an XSLT stylesheet |
setXSL | public void setXSL(String sslUri, String stylesheetTitle, BrowserInfo browserInfo) throws PortalException(Code) | | Configures the xsl source by choosing the appropriate stylesheet from
the provided stylesheet list file.
Parameters: sslUri - the URL of the stylesheet list file Parameters: stylesheetTitle - the title of a stylesheet within the stylesheet list file Parameters: browserInfo - the browser info object throws: org.jasig.portal.PortalException - |
transform | public static void transform(Source xmlSource, Result xmlResult, Hashtable stylesheetParams, String xslURI) throws PortalException(Code) | | Performs an XSL transformation. Accepts stylesheet parameters
(key, value pairs) stored in a Hashtable.
Parameters: xmlSource - the source to be transformedn Parameters: xmlResult - the result to be populated Parameters: stylesheetParams - a Hashtable of key/value pairs or null if no parameters Parameters: xslURI - the uri of the stylesheet to be used throws: org.jasig.portal.PortalException - if something goes wrong |
|
|