org.apache.xalan.client

Class XSLTProcessorApplet

public class XSLTProcessorApplet extends Applet

Provides applet host for the XSLT processor. To perform transformations on an HTML client:
  1. Use an <applet> tag to embed this applet in the HTML client.
  2. Use the DocumentURL and StyleURL PARAM tags or the XSLTProcessorApplet and XSLTProcessorApplet methods to specify the XML source document and XSL stylesheet.
  3. Call the XSLTProcessorApplet method (or one of the transformToHtml() methods) to perform the transformation and return the result as a String.
This class extends Applet which ultimately causes this class to implement Serializable. This is a serious restriction on this class. All fields that are not transient and not static are written-out/read-in during serialization. So even private fields essentially become part of the API. Developers need to take care when modifying fields.

UNKNOWN: general

Constructor Summary
XSLTProcessorApplet()
The XSLTProcessorApplet constructor takes no arguments.
Method Summary
voiddestroy()
Cleanup; called when applet is terminated and unloaded.
StringescapeString(String s)
Given a String containing markup, escape the markup so it can be displayed in the browser.
voidfreeCache()
The processor keeps a cache of the source and style trees, so call this method if they have changed or you want to do garbage collection.
StringgetAppletInfo()
Get basic information about the applet
StringgetHtmlText()
Assuming the stylesheet URL and the input XML URL have been set, perform the transformation and return the result as a String.
String[][]getParameterInfo()
Get descriptions of the applet parameters.
StringgetResultTreeAsText()
Get the HTML result Tree as a text string suitable for display in a browser.
StringgetSourceTreeAsText()
Get the XML source Tree as a text string suitable for display in a browser.
StringgetStyleTreeAsText()
Get the XSL style Tree as a text string suitable for display in a browser.
StringgetTreeAsText(String treeURL)
Get an XML document (or stylesheet)
voidinit()
Standard applet initialization.
voidpaint(Graphics g)
Do not call; this applet contains no UI or visual components.
voidsetDocumentURL(String urlString)
Set the URL to the XML document that will be transformed with the XSL stylesheet.
voidsetStylesheetParam(String key, String expr)
Submit a stylesheet parameter.
voidsetStyleSheetAttribute(String nameOfIDAttrOfElemToModify, String elemId, String attrName, String value)
Set an attribute in the stylesheet, which gives the ability to have some dynamic selection control.
voidsetStyleURL(String urlString)
Set the URL to the XSL stylesheet that will be used to transform the input XML.
voidstart()
Automatically called when the HTML client containing the applet loads.
voidstop()
Automatically called when the HTML page containing the applet is no longer on the screen.
StringtransformToHtml(String doc, String style)
Process a document and a stylesheet and return the transformation result.
StringtransformToHtml(String doc)
Process a document and a stylesheet and return the transformation result.

Constructor Detail

XSLTProcessorApplet

public XSLTProcessorApplet()
The XSLTProcessorApplet constructor takes no arguments.

Method Detail

destroy

public void destroy()
Cleanup; called when applet is terminated and unloaded.

escapeString

public String escapeString(String s)
Given a String containing markup, escape the markup so it can be displayed in the browser.

Parameters: s String to escape The escaped string.

freeCache

public void freeCache()
The processor keeps a cache of the source and style trees, so call this method if they have changed or you want to do garbage collection.

getAppletInfo

public String getAppletInfo()
Get basic information about the applet

Returns: A String with the applet name and author.

getHtmlText

public String getHtmlText()
Assuming the stylesheet URL and the input XML URL have been set, perform the transformation and return the result as a String.

Returns: A string that contains the contents pointed to by the URL.

getParameterInfo

public String[][] getParameterInfo()
Get descriptions of the applet parameters.

Returns: A two-dimensional array of Strings with Name, Type, and Description for each parameter.

getResultTreeAsText

public String getResultTreeAsText()
Get the HTML result Tree as a text string suitable for display in a browser. Note that this is for display of the XML itself, not for rendering of HTML by the browser.

Returns: Transformation result as unmarked text.

Throws: Exception thrown if tree can not be converted.

getSourceTreeAsText

public String getSourceTreeAsText()
Get the XML source Tree as a text string suitable for display in a browser. Note that this is for display of the XML itself, not for rendering of HTML by the browser.

Returns: XML source document as a string.

Throws: Exception thrown if tree can not be converted.

getStyleTreeAsText

public String getStyleTreeAsText()
Get the XSL style Tree as a text string suitable for display in a browser. Note that this is for display of the XML itself, not for rendering of HTML by the browser.

Returns: The XSL stylesheet as a string.

Throws: Exception thrown if tree can not be converted.

getTreeAsText

public String getTreeAsText(String treeURL)
Get an XML document (or stylesheet)

Parameters: treeURL valid URL string for the document.

Returns: document

Throws: IOException

init

public void init()
Standard applet initialization.

paint

public void paint(Graphics g)
Do not call; this applet contains no UI or visual components.

setDocumentURL

public void setDocumentURL(String urlString)
Set the URL to the XML document that will be transformed with the XSL stylesheet. No processing is done yet.

Parameters: urlString valid URL string for XML document.

setStylesheetParam

public void setStylesheetParam(String key, String expr)
Submit a stylesheet parameter.

Parameters: key stylesheet parameter key expr the parameter expression to be submitted.

See Also: javax.xml.transform.Transformer#setParameter(String,Object)

setStyleSheetAttribute

public void setStyleSheetAttribute(String nameOfIDAttrOfElemToModify, String elemId, String attrName, String value)
Set an attribute in the stylesheet, which gives the ability to have some dynamic selection control.

Parameters: nameOfIDAttrOfElemToModify The name of an attribute to search for a unique id. elemId The unique ID to look for. attrName Once the element is found, the name of the attribute to set. value The value to set the attribute to.

setStyleURL

public void setStyleURL(String urlString)
Set the URL to the XSL stylesheet that will be used to transform the input XML. No processing is done yet.

Parameters: urlString valid URL string for XSL stylesheet.

start

public void start()
Automatically called when the HTML client containing the applet loads. This method starts execution of the applet thread.

stop

public void stop()
Automatically called when the HTML page containing the applet is no longer on the screen. Stops execution of the applet thread.

transformToHtml

public String transformToHtml(String doc, String style)
Process a document and a stylesheet and return the transformation result. If one of these is null, the existing value (of a previous transformation) is not affected.

Parameters: doc URL string to XML document style URL string to XSL stylesheet

Returns: HTML transformation result

transformToHtml

public String transformToHtml(String doc)
Process a document and a stylesheet and return the transformation result. Use the xsl:stylesheet PI to find the document, if one exists.

Parameters: doc URL string to XML document containing an xsl:stylesheet PI.

Returns: HTML transformation result

Copyright B) 2005 Apache XML Project. All Rights Reserved.