org.custommonkey.xmlunit

Class Transform

public class Transform extends Object

Handy wrapper for an XSLT transformation performed using JAXP/Trax. Note that transformation is not actually performed until a call to getResultXXX method, and Templates are not used.
Examples and more at xmlunit.sourceforge.net
Constructor Summary
Transform(String input, String stylesheet)
Create a transformation using String input XML and String stylesheet
Transform(String input, File stylesheet)
Create a transformation using String input XML and stylesheet in a File
Transform(Node sourceNode)
Create a transformation that allows us to serialize a DOM Node
Transform(Node sourceNode, String stylesheet)
Create a transformation from an input Node and stylesheet in a String
Transform(Node sourceNode, File stylesheet)
Create a transformation from an input Node and stylesheet in a File
Transform(Source inputSource, Source stylesheetSource)
Create a transformation using Source input XML and Source stylesheet
Method Summary
voidclearParameters()
Clear parameters used for the transformation
ObjectgetParameter(String name)
See a parameter used for the transformation
DocumentgetResultDocument()
Perform the XSLT transformation specified in the constructor
StringgetResultString()
Perform the XSLT transformation specified in the constructor
voidsetErrorListener(ErrorListener errorListener)
Set the ErrorListener for the transformation
voidsetOutputProperties(Properties outputProperties)
Override output properties specified in the transformation stylesheet
voidsetOutputProperty(String name, String value)
Override an output property specified in the transformation stylesheet
voidsetParameter(String name, Object value)
Add a parameter for the transformation
voidsetURIResolver(URIResolver uriResolver)
Set the URIResolver for the transformation
protected voidtransformTo(Result result)
Perform the actual transformation

Constructor Detail

Transform

public Transform(String input, String stylesheet)
Create a transformation using String input XML and String stylesheet

Parameters: input stylesheet

Throws: TransformerConfigurationException

Transform

public Transform(String input, File stylesheet)
Create a transformation using String input XML and stylesheet in a File

Parameters: input stylesheet

Throws: TransformerConfigurationException

Transform

public Transform(Node sourceNode)
Create a transformation that allows us to serialize a DOM Node

Parameters: source

Throws: TransformerConfigurationException

Transform

public Transform(Node sourceNode, String stylesheet)
Create a transformation from an input Node and stylesheet in a String

Parameters: sourceNode stylesheet

Throws: TransformerConfigurationException

Transform

public Transform(Node sourceNode, File stylesheet)
Create a transformation from an input Node and stylesheet in a File

Parameters: sourceNode stylesheet

Throws: TransformerConfigurationException

Transform

public Transform(Source inputSource, Source stylesheetSource)
Create a transformation using Source input XML and Source stylesheet

Parameters: inputReader stylesheetReader

Throws: TransformerConfigurationException

Method Detail

clearParameters

public void clearParameters()
Clear parameters used for the transformation

See Also: Transformer#clearParameters()

getParameter

public Object getParameter(String name)
See a parameter used for the transformation

Parameters: name

Returns: the parameter value

See Also: Transformer#getParameter(java.lang.String)

getResultDocument

public Document getResultDocument()
Perform the XSLT transformation specified in the constructor

Returns: the result as a DOM Document

Throws: TransformerException

getResultString

public String getResultString()
Perform the XSLT transformation specified in the constructor

Returns: the result as a String

Throws: TransformerException

setErrorListener

public void setErrorListener(ErrorListener errorListener)
Set the ErrorListener for the transformation

See Also: Transformer#setErrorListener(javax.xml.transform.ErrorListener)

setOutputProperties

public void setOutputProperties(Properties outputProperties)
Override output properties specified in the transformation stylesheet

Parameters: outputProperties

See Also: Transformer#setOutputProperties(java.util.Properties)

setOutputProperty

public void setOutputProperty(String name, String value)
Override an output property specified in the transformation stylesheet

Parameters: name value

setParameter

public void setParameter(String name, Object value)
Add a parameter for the transformation

Parameters: name value

See Also: Transformer#setParameter(java.lang.String, java.lang.Object)

setURIResolver

public void setURIResolver(URIResolver uriResolver)
Set the URIResolver for the transformation

See Also: Transformer#setURIResolver(javax.xml.transform.URIResolver)

transformTo

protected void transformTo(Result result)
Perform the actual transformation

Parameters: result

Throws: TransformerException