|
uPortal 2.4.1 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jasig.portal.utils.XSLT
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();
Constructor Summary | |
XSLT(java.lang.Object instance)
Constructs an XSLT object. |
Method Summary | |
static javax.xml.transform.sax.SAXTransformerFactory |
getSAXTFactory()
|
static StylesheetSet |
getStylesheetSet(java.lang.String stylesheetListURI)
This method caches compiled stylesheet set objects, keyed by the stylesheet list's URI. |
static java.lang.String |
getStylesheetURI(java.lang.String sslUri,
BrowserInfo browserInfo)
Returns a stylesheet URI exactly as it appears in a stylesheet list file. |
static java.lang.String |
getStylesheetURI(java.lang.String sslUri,
java.lang.String title,
BrowserInfo browserInfo)
Returns a stylesheet URI exactly as it appears in a stylesheet list file. |
static javax.xml.transform.Templates |
getTemplates(java.lang.String stylesheetURI)
This method caches compiled stylesheet objects, keyed by the stylesheet's URI. |
static javax.xml.transform.Templates |
getTemplates(java.lang.String stylesheetURI,
java.util.ResourceBundle l18n)
This method caches compiled stylesheet objects, keyed by the stylesheet's URI and locale. |
static XSLT |
getTransformer(java.lang.Object instance)
Factory method that produces an XSLT transformer utility. |
static XSLT |
getTransformer(java.lang.Object instance,
java.util.Locale[] locales)
Factory method that produces an XSLT transformer utility with a capability of choosing a stylesheet depending on a list of locales. |
static javax.xml.transform.Transformer |
getTransformer(java.lang.String stylesheetURI)
This method returns a Transformer for a given stylesheet. |
static javax.xml.transform.Transformer |
getTransformer(java.lang.String stylesheetURI,
java.util.ResourceBundle l18n)
This method returns a localized Transformer for a given stylesheet. |
static javax.xml.transform.sax.TransformerHandler |
getTransformerHandler(java.lang.String stylesheetURI)
This method returns a TransformerHandler for a given stylesheet. |
static javax.xml.transform.sax.TransformerHandler |
getTransformerHandler(java.lang.String stylesheetURI,
java.util.Locale[] locales,
java.lang.Object caller)
This method returns a localized TransformerHandler for a given stylesheet. |
void |
setResourceBundle(java.util.ResourceBundle bundle)
|
void |
setStylesheetParameter(java.lang.String name,
java.lang.String value)
Sets all the stylesheet parameters at once. |
void |
setStylesheetParameters(java.util.HashMap stylesheetParameters)
Sets all the stylesheet parameters at once. |
void |
setStylesheetParameters(java.util.Hashtable stylesheetParameters)
Sets all the stylesheet parameters at once. |
void |
setTarget(org.xml.sax.ContentHandler contentHandler)
Configures the xslt target. |
void |
setTarget(org.w3c.dom.Node node)
Configures the xslt target. |
void |
setTarget(java.io.OutputStream os)
Configures the xslt target. |
void |
setXML(java.io.File file)
Configures the xml source. |
void |
setXML(java.io.InputStream is)
Configures the xml source. |
void |
setXML(org.w3c.dom.Node xml)
Configures the xml source. |
void |
setXML(java.lang.String xml)
Configures the xml source. |
void |
setXSL(java.lang.String xslUri)
Configures the xsl source. |
void |
setXSL(java.lang.String sslUri,
BrowserInfo browserInfo)
Configures the xsl source by choosing the appropriate stylesheet from the provided stylesheet list file. |
void |
setXSL(java.lang.String sslUri,
java.lang.String stylesheetTitle,
BrowserInfo browserInfo)
Configures the xsl source by choosing the appropriate stylesheet from the provided stylesheet list file. |
void |
transform()
Performs a transformation. |
static void |
transform(javax.xml.transform.Source xmlSource,
javax.xml.transform.Result xmlResult,
java.util.Hashtable stylesheetParams,
java.lang.String xslURI)
Performs an XSL transformation. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XSLT(java.lang.Object instance)
instance
- the client of this utilityMethod Detail |
public static XSLT getTransformer(java.lang.Object instance)
instance
- the client of this utility
public static XSLT getTransformer(java.lang.Object instance, java.util.Locale[] locales)
instance
- the client of this utility
public static javax.xml.transform.sax.SAXTransformerFactory getSAXTFactory()
public void setXML(java.lang.String xml)
xml
- a string representing the xml documentpublic void setXML(org.w3c.dom.Node xml)
xml
- a node representing the xml documentpublic void setXML(java.io.InputStream is)
is
- an input stream to the serialized xml sourcepublic void setXML(java.io.File file)
file
- a File object representing the xml sourcepublic void setXSL(java.lang.String xslUri) throws PortalException
xslUri
- the URL of an XSLT stylesheet
PortalException
public void setXSL(java.lang.String sslUri, java.lang.String stylesheetTitle, BrowserInfo browserInfo) throws PortalException
sslUri
- the URL of the stylesheet list filestylesheetTitle
- the title of a stylesheet within the stylesheet list filebrowserInfo
- the browser info object
PortalException
public void setXSL(java.lang.String sslUri, BrowserInfo browserInfo) throws PortalException
sslUri
- the URL of the stylesheet list filebrowserInfo
- the browser info object
PortalException
public void setTarget(org.xml.sax.ContentHandler contentHandler)
contentHandler
- the content handlerpublic void setTarget(java.io.OutputStream os)
os
- output streampublic void setTarget(org.w3c.dom.Node node)
node
- target nodepublic void setStylesheetParameters(java.util.Hashtable stylesheetParameters)
stylesheetParameters
- a Hashtable of stylesheet parameterspublic void setStylesheetParameters(java.util.HashMap stylesheetParameters)
stylesheetParameters
- a HashMap of stylesheet parameterspublic void setStylesheetParameter(java.lang.String name, java.lang.String value)
name
- the name of the stylesheet parametervalue
- the value of the stylesheet parameterpublic void transform() throws PortalException
PortalException
public static void transform(javax.xml.transform.Source xmlSource, javax.xml.transform.Result xmlResult, java.util.Hashtable stylesheetParams, java.lang.String xslURI) throws PortalException
xmlSource
- the source to be transformednxmlResult
- the result to be populatedstylesheetParams
- a Hashtable of key/value pairs or null
if no parametersxslURI
- the uri of the stylesheet to be used
PortalException
- if something goes wrongpublic void setResourceBundle(java.util.ResourceBundle bundle)
public static javax.xml.transform.Templates getTemplates(java.lang.String stylesheetURI, java.util.ResourceBundle l18n) throws org.xml.sax.SAXException, PortalException, javax.xml.transform.TransformerConfigurationException
stylesheetURI
- the URI of the XSLT stylesheetl18n
- the localized strings to add to the xsl
org.xml.sax.SAXException
PortalException
javax.xml.transform.TransformerConfigurationException
public static javax.xml.transform.Templates getTemplates(java.lang.String stylesheetURI) throws org.xml.sax.SAXException, PortalException
stylesheetURI
- the URI of the XSLT stylesheet
org.xml.sax.SAXException
PortalException
public static javax.xml.transform.Transformer getTransformer(java.lang.String stylesheetURI, java.util.ResourceBundle l18n) throws org.xml.sax.SAXException, PortalException
stylesheetURI
- the URI of the XSLT stylesheet
Transformer
org.xml.sax.SAXException
PortalException
public static javax.xml.transform.Transformer getTransformer(java.lang.String stylesheetURI) throws org.xml.sax.SAXException, PortalException
stylesheetURI
- the URI of the XSLT stylesheet
Transformer
org.xml.sax.SAXException
PortalException
public static javax.xml.transform.sax.TransformerHandler getTransformerHandler(java.lang.String stylesheetURI) throws org.xml.sax.SAXException, PortalException
stylesheetURI
- the URI of the XSLT stylesheet
Transformer
org.xml.sax.SAXException
PortalException
public static javax.xml.transform.sax.TransformerHandler getTransformerHandler(java.lang.String stylesheetURI, java.util.Locale[] locales, java.lang.Object caller) throws org.xml.sax.SAXException, PortalException
stylesheetURI
- the URI of the XSLT stylesheetlocales
- the list of localescaller
- the calling class
Transformer
org.xml.sax.SAXException
PortalException
public static StylesheetSet getStylesheetSet(java.lang.String stylesheetListURI) throws PortalException
stylesheetListURI
- the URI of the XSLT stylesheet list file (.ssl)
PortalException
public static java.lang.String getStylesheetURI(java.lang.String sslUri, BrowserInfo browserInfo) throws PortalException
sslUri
- the stylesheet list file URIbrowserInfo
- the browser information
PortalException
public static java.lang.String getStylesheetURI(java.lang.String sslUri, java.lang.String title, BrowserInfo browserInfo) throws PortalException
sslUri
- the stylesheet list file URItitle
- the stylesheet titlebrowserInfo
- the browser information
PortalException
|
uPortal 2.4.1 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |