com.xml_project.morganaxproc.connectors
Class XSLTConnector

java.lang.Object
  extended by com.xml_project.morganaxproc.connectors.XSLTConnector

public abstract class XSLTConnector
extends java.lang.Object

This class defines an interface for the use of XSLT processors with MorganaXProc. It allows you to use any XSLT processor you like in 'p:xslt' by just wrapping an XSLTConnector around it.

The interface to XSLT processors comes in two classes:


Field Summary
static java.lang.String EXECUTION_TERMINATED
          Error code for user terminated transformation.
static java.lang.String FEATURE_NOT_AVAILABLE
          Error code for a feature not supported by the connector or the underlying processor.
static java.lang.String UNKNOWN_INITIAL_TEMPLATE_OR_MODE
          Error code for an unknown initial template or mode.
 
Constructor Summary
XSLTConnector()
           
 
Method Summary
abstract  void addXPathFunction(XPathFunction function)
          Adds an user written XPath extension function to the list of visible functions in XSLT
abstract  XSLTTemplate compile(nu.xom.Document template)
          Creates an executable form a the template
abstract  java.lang.String getInfoString()
          Defines a string displayed on the standard output stream the first time, an instance of the connector is generated.
abstract  java.lang.String getShortInfo()
          Defines a string to be used in TestReporter
abstract  boolean implementsVersion(java.lang.String version)
          Checks whether the XSLT processor used in this connector supports a specific version of XSLT.
abstract  java.util.List<XPathFunction> importXPathFunctions(nu.xom.Document template)
          Compile an xslt stylesheet and makes all XPath functions available as result.
static XSLTConnector newInstance(java.lang.String className, java.io.PrintWriter infoWriter, java.io.PrintStream messageStream)
          Creates a new instance of an XSLTConnector using the given class name.
static XSLTConnector newInstance(XProcConfiguration config, java.io.PrintWriter infoWriter, java.io.PrintStream messageStream)
          Creates a new instance of an XSLTConnector using the class defined in XProcConfiguration.
abstract  void setErrorListener(javax.xml.transform.ErrorListener listener)
          Sets the error listener for compilation.
abstract  void setImportURIResolver(javax.xml.transform.URIResolver resolver)
          Sets uri resolver to resolve stylesheet import with xsl:import and xsl:include.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_INITIAL_TEMPLATE_OR_MODE

public static final java.lang.String UNKNOWN_INITIAL_TEMPLATE_OR_MODE
Error code for an unknown initial template or mode.

See Also:
Constant Field Values

EXECUTION_TERMINATED

public static final java.lang.String EXECUTION_TERMINATED
Error code for user terminated transformation.

See Also:
Constant Field Values

FEATURE_NOT_AVAILABLE

public static final java.lang.String FEATURE_NOT_AVAILABLE
Error code for a feature not supported by the connector or the underlying processor.

See Also:
Constant Field Values
Constructor Detail

XSLTConnector

public XSLTConnector()
Method Detail

getInfoString

public abstract java.lang.String getInfoString()
Defines a string displayed on the standard output stream the first time, an instance of the connector is generated. This method should be used to return copyright information of the used XSLT processor.

Returns:
a string identifying the used XSLT processor for the user including copyright information.

getShortInfo

public abstract java.lang.String getShortInfo()
Defines a string to be used in TestReporter

Returns:
a string naming product and product version

implementsVersion

public abstract boolean implementsVersion(java.lang.String version)
Checks whether the XSLT processor used in this connector supports a specific version of XSLT. The requested version is given as a string in the form "1.0".

Parameters:
version - the requested version
Returns:
true if this version is supported, otherwise false

setErrorListener

public abstract void setErrorListener(javax.xml.transform.ErrorListener listener)
Sets the error listener for compilation.

Parameters:
listener - the error listener for compilation.

setImportURIResolver

public abstract void setImportURIResolver(javax.xml.transform.URIResolver resolver)
Sets uri resolver to resolve stylesheet import with xsl:import and xsl:include.

Parameters:
resolver - the URIResolver to be used by MorganaXProc.

addXPathFunction

public abstract void addXPathFunction(XPathFunction function)
                               throws XPathException
Adds an user written XPath extension function to the list of visible functions in XSLT

Parameters:
function - the function to add.
Throws:
XPathException - if the function cannot be casted.

compile

public abstract XSLTTemplate compile(nu.xom.Document template)
                              throws javax.xml.transform.TransformerException
Creates an executable form a the template

Parameters:
template - the stylesheet
Returns:
an executable form of the stylesheet
Throws:
javax.xml.transform.TransformerException - if any error occurs during compilation

importXPathFunctions

public abstract java.util.List<XPathFunction> importXPathFunctions(nu.xom.Document template)
                                                            throws javax.xml.transform.TransformerException
Compile an xslt stylesheet and makes all XPath functions available as result.

Parameters:
template - the stylesheet
Returns:
a (possibly empty) list of XPathFunctions declared in this stylesheet
Throws:
javax.xml.transform.TransformerException - if any error occurs during compilation or import is not supported.

newInstance

public static final XSLTConnector newInstance(XProcConfiguration config,
                                              java.io.PrintWriter infoWriter,
                                              java.io.PrintStream messageStream)
                                       throws javax.xml.transform.TransformerFactoryConfigurationError
Creates a new instance of an XSLTConnector using the class defined in XProcConfiguration. This method is called before the execution of the pipeline by MorganaXProc.

Parameters:
config - the XProcConfiguration to use.
infoWriter - the PrintWriter for messages or null
messageStream - the PrintStream for copyright messages.
Returns:
the newly created XSLTConnector.
Throws:
javax.xml.transform.TransformerFactoryConfigurationError - if any exception occurs in creating the new XSLTConnector.

newInstance

public static final XSLTConnector newInstance(java.lang.String className,
                                              java.io.PrintWriter infoWriter,
                                              java.io.PrintStream messageStream)
                                       throws javax.xml.transform.TransformerFactoryConfigurationError
Creates a new instance of an XSLTConnector using the given class name. This method is called before the execution of the pipeline by MorganaXProc.

Parameters:
className - the class name for the new connector.
infoWriter - the PrintWriter for messages or null
messageStream - the PrintStream for copyright messages.
Returns:
the newly created XSLTConnector.
Throws:
javax.xml.transform.TransformerFactoryConfigurationError - if any exception occurs in creating the new XSLTConnector.