Class TransformerImpl
- java.lang.Object
-
- javax.xml.transform.Transformer
-
- net.sf.saxon.jaxp.IdentityTransformer
-
- net.sf.saxon.jaxp.TransformerImpl
-
public class TransformerImpl extends IdentityTransformer
Saxon implementation of the JAXP Transformer interface.Since Saxon 9.6, JAXP interfaces are implemented as a layer above the s9api interface
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TransformerImpl(XsltExecutable e, XsltTransformer t)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearParameters()
Clear all parameters set with setParameter.java.lang.Object
getParameter(java.lang.String name)
Get a parameter that was explicitly set with setParameter.protected java.util.Properties
getStylesheetOutputProperties()
Get the output properties defined in the unnamed xsl:output declaration(s) within the stylesheetXsltController
getUnderlyingController()
Get the internal Saxon Controller instance that implements this transformation.XsltExecutable
getUnderlyingXsltExecutable()
Get the underlying s9api implementation class representing the compled stylesheet which this transformer is executingXsltTransformer
getUnderlyingXsltTransformer()
Get the underlying s9api implementation class wrapped by this JAXP Transformerjavax.xml.transform.sax.TransformerHandler
newTransformerHandler()
Create a JAXP TransformerHandler to perform the transformationorg.xml.sax.XMLFilter
newXMLFilter()
Create a JAXP XMLFilter which allows this transformation to be added to a SAX pipelinevoid
reset()
Reset thisTransformer
to its original configuration.protected void
setConvertedParameter(QName name, XdmValue value)
void
setErrorListener(javax.xml.transform.ErrorListener listener)
Set the error event listener in effect for the transformation.void
setInitialMode(java.lang.String name)
Supply an initial mode for a transformation.void
setInitialTemplate(java.lang.String name)
Supply an initial template for a transformation.void
setParameter(java.lang.String name, java.lang.Object value)
Add a parameter for the transformation.void
setURIResolver(javax.xml.transform.URIResolver resolver)
Set an object that will be used to resolve URIs used in document().void
transform(javax.xml.transform.Source xmlSource, javax.xml.transform.Result outputTarget)
Transform the XMLSource
to aResult
.-
Methods inherited from class net.sf.saxon.jaxp.IdentityTransformer
getConfiguration, getErrorListener, getLocalOutputProperties, getOutputProperties, getOutputProperty, getURIResolver, reportFatalError, setOutputProperties, setOutputProperty
-
-
-
-
Constructor Detail
-
TransformerImpl
protected TransformerImpl(XsltExecutable e, XsltTransformer t)
-
-
Method Detail
-
transform
public void transform(javax.xml.transform.Source xmlSource, javax.xml.transform.Result outputTarget) throws XPathException
Transform the XML
Source
to aResult
. Specific transformation behavior is determined by the settings of theTransformerFactory
in effect when theTransformer
was instantiated and any modifications made to theTransformer
instance.An empty
Source
is represented as an empty document as constructed byDocumentBuilder.newDocument()
. The result of transforming an emptySource
depends on the transformation behavior; it is not always an emptyResult
.- Overrides:
transform
in classIdentityTransformer
- Parameters:
xmlSource
- The XML input to transform.outputTarget
- TheResult
of transforming thexmlSource
.- Throws:
XPathException
- If an unrecoverable error occurs during the course of the transformation.
-
clearParameters
public void clearParameters()
Clear all parameters set with setParameter.
-
setURIResolver
public void setURIResolver(javax.xml.transform.URIResolver resolver)
Set an object that will be used to resolve URIs used in document().If the resolver argument is null, the URIResolver value will be cleared and the transformer will no longer have a resolver.
- Overrides:
setURIResolver
in classIdentityTransformer
- Parameters:
resolver
- An object that implements the URIResolver interface, or null.
-
setErrorListener
public void setErrorListener(javax.xml.transform.ErrorListener listener) throws java.lang.IllegalArgumentException
Set the error event listener in effect for the transformation.- Overrides:
setErrorListener
in classIdentityTransformer
- Parameters:
listener
- The new error listener.- Throws:
java.lang.IllegalArgumentException
- if listener is null.
-
setInitialTemplate
public void setInitialTemplate(java.lang.String name)
Supply an initial template for a transformation.This is a Saxon extension to the JAXP interface, needed for XSLT 2.0
Changed in 9.9 so it no longer validates the supplied name; an incorrect name will lead to an error later.
- Parameters:
name
- the name of the initial template, in Clark notation (either a local name, or "{uri}local")
-
setInitialMode
public void setInitialMode(java.lang.String name) throws java.lang.IllegalArgumentException
Supply an initial mode for a transformation.This is a Saxon extension to the JAXP interface, needed for XSLT 2.0
- Parameters:
name
- the name of the initial mode, in Clark notation (either a local name, or "{uri}local")- Throws:
java.lang.IllegalArgumentException
- if the argument is invalid, for example if the format of the name is incorrect or if there is no mode with this name or if the mode is private
-
getUnderlyingXsltTransformer
public XsltTransformer getUnderlyingXsltTransformer()
Get the underlying s9api implementation class wrapped by this JAXP Transformer- Returns:
- the underlying s9api XsltTransformer
-
getUnderlyingController
public XsltController getUnderlyingController()
Get the internal Saxon Controller instance that implements this transformation. Note that the Controller interface will not necessarily remain stable in future releases- Returns:
- the underlying Saxon Controller instance
-
newTransformerHandler
public javax.xml.transform.sax.TransformerHandler newTransformerHandler()
Create a JAXP TransformerHandler to perform the transformation- Returns:
- a JAXP TransformerHandler, which allows the transformation to be performed in "push" mode on a SAX pipeline.
-
newXMLFilter
public org.xml.sax.XMLFilter newXMLFilter()
Create a JAXP XMLFilter which allows this transformation to be added to a SAX pipeline- Returns:
- the transformation in the form of an XMLFilter
-
reset
public void reset()
Description copied from class:IdentityTransformer
Reset this
Transformer
to its original configuration.Transformer
is reset to the same state as when it was created withTransformerFactory.newTransformer()
,TransformerFactory.newTransformer(javax.xml.transform.Source source)
orTemplates.newTransformer()
.reset()
is designed to allow the reuse of existingTransformer
s thus saving resources associated with the creation of newTransformer
s.The reset
Transformer
is not guaranteed to have the sameURIResolver
orErrorListener
Object
s, e.g.Object.equals(Object obj)
. It is guaranteed to have a functionally equalURIResolver
andErrorListener
.- Overrides:
reset
in classIdentityTransformer
-
setParameter
public void setParameter(java.lang.String name, java.lang.Object value)
Add a parameter for the transformation.Pass a qualified name as a two-part string, the namespace URI enclosed in curly braces ({}), followed by the local name. If the name has a null URL, the String only contain the local name. An application can safely check for a non-null URI by testing to see if the first character of the name is a '{' character.
For example, if a URI and local name were obtained from an element defined with <xyz:foo xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>, then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo". Note that no prefix is used.
- Overrides:
setParameter
in classIdentityTransformer
- Parameters:
name
- The name of the parameter, which may begin with a namespace URI in curly braces ({}).value
- The value object. This can be any valid Java object. It is up to the processor to provide the proper object coercion or to simply pass the object on for use in an extension.- Throws:
java.lang.NullPointerException
- If value is null.java.lang.IllegalArgumentException
- If the supplied value cannot be converted to the declared type of the corresponding stylesheet parameter
-
getParameter
public java.lang.Object getParameter(java.lang.String name)
Get a parameter that was explicitly set with setParameter.This method does not return a default parameter value, which cannot be determined until the node context is evaluated during the transformation process.
- Overrides:
getParameter
in classIdentityTransformer
- Parameters:
name
- ofObject
to get- Returns:
- A parameter that has been set with setParameter, or null if no parameter with this name has been set.
-
getStylesheetOutputProperties
protected java.util.Properties getStylesheetOutputProperties()
Get the output properties defined in the unnamed xsl:output declaration(s) within the stylesheet- Overrides:
getStylesheetOutputProperties
in classIdentityTransformer
- Returns:
- the values of output properties set in the stylesheet
-
getUnderlyingXsltExecutable
public XsltExecutable getUnderlyingXsltExecutable()
Get the underlying s9api implementation class representing the compled stylesheet which this transformer is executing- Returns:
- the underlying s9api XsltExecutable
-
-