mx4j.adaptor.http
Class XSLTProcessor

java.lang.Object
  |
  +--mx4j.adaptor.http.XSLTProcessor
All Implemented Interfaces:
ProcessorMBean, javax.xml.transform.URIResolver, XSLTProcessorMBean

public class XSLTProcessor
extends java.lang.Object
implements ProcessorMBean, XSLTProcessorMBean, javax.xml.transform.URIResolver

XSLTPostProcessor pass the document through an XSLT transformation

Version:
$Revision: 1.2 $
Author:
Carlos Quiroz

Constructor Summary
XSLTProcessor()
           
 
Method Summary
 void addMimeType(java.lang.String extension, java.lang.String type)
          Adds a mime type if the defaults one are not enough.
protected  javax.xml.transform.Transformer createTransformer(java.lang.String path)
           
 java.lang.String getFile()
          Returns the file or dir containing the transformation files
protected  java.io.InputStream getInputStream(java.lang.String path)
           
 java.lang.String getName()
           
 java.lang.String getPathInJar()
          Returns the path of the files in the jar file.
 boolean isUseCache()
           
 boolean isUseJar()
          Indicates whether the xsl files are read form a jar file
 boolean isUsePath()
          Indicates whether the xsl files are read form a dir in the filesystem
 java.lang.String notFoundElement(java.lang.String path, mx4j.adaptor.http.HttpOutputStream out, mx4j.adaptor.http.HttpInputStream in)
          Let the processor load internally a not found element.
 java.lang.String preProcess(java.lang.String path)
          Preprocess a path and return a replacement path.
 javax.xml.transform.Source resolve(java.lang.String href, java.lang.String base)
           
 void setFile(java.lang.String file)
          Sets the root file of the transformation files.
 void setPathInJar(java.lang.String path)
          If you are using a .jar or .zip file, you may use the root path indicating the location of the files in the jar.
 void setUseCache(boolean useCache)
          Use cache.
 void writeError(mx4j.adaptor.http.HttpOutputStream out, mx4j.adaptor.http.HttpInputStream in, java.lang.Exception e)
          The method will process the result exception and produce output.
 void writeResponse(mx4j.adaptor.http.HttpOutputStream out, mx4j.adaptor.http.HttpInputStream in, org.w3c.dom.Document document)
          The method will process the result string and produce an output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XSLTProcessor

public XSLTProcessor()
Method Detail

writeResponse

public void writeResponse(mx4j.adaptor.http.HttpOutputStream out,
                          mx4j.adaptor.http.HttpInputStream in,
                          org.w3c.dom.Document document)
                   throws java.io.IOException
Description copied from interface: ProcessorMBean
The method will process the result string and produce an output. The implementor is also responsible to set the mime type, response code and send the headers before answering as follow: out.setCode(HttpConstants.STATUS_OKAY); out.setHeader("Content-type", "text/html"); out.sendHeaders(); out.write("some text");
Specified by:
writeResponse in interface ProcessorMBean
Following copied from interface: mx4j.adaptor.http.ProcessorMBean
Parameters:
out - The output stream
in - The input stream
document - A document containing the data

createTransformer

protected javax.xml.transform.Transformer createTransformer(java.lang.String path)

writeError

public void writeError(mx4j.adaptor.http.HttpOutputStream out,
                       mx4j.adaptor.http.HttpInputStream in,
                       java.lang.Exception e)
                throws java.io.IOException
Description copied from interface: ProcessorMBean
The method will process the result exception and produce output. The implementor is also responsible to set the mime type, response code and send the headers before answering as follow: out.setCode(HttpConstants.STATUS_OKAY); out.setHeader("Content-type", "text/html"); out.sendHeaders(); out.write("some text");
Specified by:
writeError in interface ProcessorMBean
Following copied from interface: mx4j.adaptor.http.ProcessorMBean
Parameters:
out - The output stream
in - The input stream
e - The exception to be reported

preProcess

public java.lang.String preProcess(java.lang.String path)
Description copied from interface: ProcessorMBean
Preprocess a path and return a replacement path. For instance the / path could be replaced by the server path
Specified by:
preProcess in interface ProcessorMBean
Following copied from interface: mx4j.adaptor.http.ProcessorMBean
Parameters:
path - The original path
Returns:
the replacement path. If not modification the path param should be returned

notFoundElement

public java.lang.String notFoundElement(java.lang.String path,
                                        mx4j.adaptor.http.HttpOutputStream out,
                                        mx4j.adaptor.http.HttpInputStream in)
                                 throws java.io.IOException,
                                        mx4j.adaptor.http.HttpException
Description copied from interface: ProcessorMBean
Let the processor load internally a not found element. This can be used to load images, stylesheets and so on. If return is not null, the path is processed
Specified by:
notFoundElement in interface ProcessorMBean
Following copied from interface: mx4j.adaptor.http.ProcessorMBean
Parameters:
path - The request element
out - The output stream
in - The input stream

getInputStream

protected java.io.InputStream getInputStream(java.lang.String path)

resolve

public javax.xml.transform.Source resolve(java.lang.String href,
                                          java.lang.String base)
Specified by:
resolve in interface javax.xml.transform.URIResolver

setFile

public void setFile(java.lang.String file)
Description copied from interface: XSLTProcessorMBean
Sets the root file of the transformation files. The XSLT processor requires to know where the XSLT and other files are. If the path points to a .jar or .zip file, then the files are directly loaded from it. If not the files are loaded directly from file. If null the files carried on the same class' jar are used. If you use a .jar or .zip set also the root path
Specified by:
setFile in interface XSLTProcessorMBean

getFile

public java.lang.String getFile()
Description copied from interface: XSLTProcessorMBean
Returns the file or dir containing the transformation files
Specified by:
getFile in interface XSLTProcessorMBean

getPathInJar

public java.lang.String getPathInJar()
Description copied from interface: XSLTProcessorMBean
Returns the path of the files in the jar file.
Specified by:
getPathInJar in interface XSLTProcessorMBean

setPathInJar

public void setPathInJar(java.lang.String path)
Description copied from interface: XSLTProcessorMBean
If you are using a .jar or .zip file, you may use the root path indicating the location of the files in the jar.
Specified by:
setPathInJar in interface XSLTProcessorMBean

isUseJar

public boolean isUseJar()
Description copied from interface: XSLTProcessorMBean
Indicates whether the xsl files are read form a jar file
Specified by:
isUseJar in interface XSLTProcessorMBean

isUsePath

public boolean isUsePath()
Description copied from interface: XSLTProcessorMBean
Indicates whether the xsl files are read form a dir in the filesystem
Specified by:
isUsePath in interface XSLTProcessorMBean

addMimeType

public void addMimeType(java.lang.String extension,
                        java.lang.String type)
Description copied from interface: XSLTProcessorMBean
Adds a mime type if the defaults one are not enough. Use as addMimeType(".gif", "image/gif");
Specified by:
addMimeType in interface XSLTProcessorMBean

setUseCache

public void setUseCache(boolean useCache)
Description copied from interface: XSLTProcessorMBean
Use cache. If set the XSLT transformation are cached. This is true by default but you may want to set it to false for development
Specified by:
setUseCache in interface XSLTProcessorMBean

isUseCache

public boolean isUseCache()
Specified by:
isUseCache in interface XSLTProcessorMBean

getName

public java.lang.String getName()
Specified by:
getName in interface ProcessorMBean