Package org.custommonkey.xmlunit
Class Transform
- java.lang.Object
-
- org.custommonkey.xmlunit.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 togetResultXXXmethod, and Templates are not used.
-
-
Constructor Summary
Constructors Constructor Description Transform(String input, File stylesheet)Create a transformation using String input XML and stylesheet in a FileTransform(String input, String stylesheet)Create a transformation using String input XML and String stylesheetTransform(Source inputSource, Source stylesheetSource)Create a transformation using Source input XML and Source stylesheetTransform(Node sourceNode)Create a transformation that allows us to serialize a DOM NodeTransform(Node sourceNode, File stylesheet)Create a transformation from an input Node and stylesheet in a FileTransform(Node sourceNode, String stylesheet)Create a transformation from an input Node and stylesheet in a StringTransform(InputSource input, File stylesheet)Create a transformation using InputSource input XML and stylesheet in a FileTransform(InputSource input, InputSource stylesheet)Create a transformation using InputSource input XML and InputSource stylesheet
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearParameters()Clear parameters used for the transformationObjectgetParameter(String name)See a parameter used for the transformationDocumentgetResultDocument()Perform the XSLT transformation specified in the constructorStringgetResultString()Perform the XSLT transformation specified in the constructorvoidsetErrorListener(ErrorListener errorListener)Set the ErrorListener for the transformationvoidsetOutputProperties(Properties outputProperties)Override output properties specified in the transformation stylesheetvoidsetOutputProperty(String name, String value)Override an output property specified in the transformation stylesheetvoidsetParameter(String name, Object value)Add a parameter for the transformationvoidsetURIResolver(URIResolver uriResolver)Set the URIResolver for the transformationprotected 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- document to transformstylesheet- stylesheet to use for transformation
-
Transform
public Transform(String input, File stylesheet)
Create a transformation using String input XML and stylesheet in a File- Parameters:
input- document to transformstylesheet- stylesheet to use for transformation
-
Transform
public Transform(InputSource input, InputSource stylesheet)
Create a transformation using InputSource input XML and InputSource stylesheet- Parameters:
input- document to transformstylesheet- stylesheet to use for transformation
-
Transform
public Transform(InputSource input, File stylesheet)
Create a transformation using InputSource input XML and stylesheet in a File- Parameters:
input- document to transformstylesheet- stylesheet to use for transformation
-
Transform
public Transform(Node sourceNode)
Create a transformation that allows us to serialize a DOM Node- Parameters:
sourceNode- document to transform
-
Transform
public Transform(Node sourceNode, String stylesheet)
Create a transformation from an input Node and stylesheet in a String- Parameters:
sourceNode- document to transformstylesheet- stylesheet to use for transformation
-
Transform
public Transform(Node sourceNode, File stylesheet)
Create a transformation from an input Node and stylesheet in a File- Parameters:
sourceNode- document to transformstylesheet- stylesheet to use for transformation
-
-
Method Detail
-
transformTo
protected void transformTo(Result result) throws TransformerException
Perform the actual transformation- Parameters:
result- result to output transformation result to- Throws:
TransformerException- if transformation fails
-
getResultString
public String getResultString() throws TransformerException
Perform the XSLT transformation specified in the constructor- Returns:
- the result as a String
- Throws:
TransformerException- if transformation fails
-
getResultDocument
public Document getResultDocument() throws TransformerException
Perform the XSLT transformation specified in the constructor- Returns:
- the result as a DOM Document
- Throws:
TransformerException- if transformation fails
-
setOutputProperty
public void setOutputProperty(String name, String value)
Override an output property specified in the transformation stylesheet- Parameters:
name- name of the propertyvalue- value of the property
-
setOutputProperties
public void setOutputProperties(Properties outputProperties)
Override output properties specified in the transformation stylesheet- Parameters:
outputProperties- output properties- See Also:
Transformer.setOutputProperties(java.util.Properties)
-
setParameter
public void setParameter(String name, Object value)
Add a parameter for the transformation- Parameters:
name- name of the parametervalue- value of the parameter- See Also:
Transformer.setParameter(java.lang.String, java.lang.Object)
-
getParameter
public Object getParameter(String name)
See a parameter used for the transformation- Parameters:
name- name of the parameter- Returns:
- the parameter value
- See Also:
Transformer.getParameter(java.lang.String)
-
clearParameters
public void clearParameters()
Clear parameters used for the transformation- See Also:
Transformer.clearParameters()
-
setURIResolver
public void setURIResolver(URIResolver uriResolver)
Set the URIResolver for the transformation- Parameters:
uriResolver- resolver to use- See Also:
Transformer.setURIResolver(javax.xml.transform.URIResolver)
-
setErrorListener
public void setErrorListener(ErrorListener errorListener)
Set the ErrorListener for the transformation- Parameters:
errorListener- error listener to use- See Also:
Transformer.setErrorListener(javax.xml.transform.ErrorListener)
-
-