public class

XMLStylesheetTransformer

extends Object
java.lang.Object
   ↳ com.computime.transformer.XMLStylesheetTransformer

Class Overview

Transforms XML using a defined stylesheet or chain of stylesheets.

Summary

Fields
private TransformerMessageReceiver messages
private TransformerErrorListener warnings_errors
Public Constructors
XMLStylesheetTransformer()
Constructor
Public Methods
String getValidationMessage()
TransformerErrorListener getWarnings_errors()
String transformFiles(String sourceXMLPath, String transformationXSLTPath, String destinationXMLPath)
Transforms the XML within the file identified through parameter 'souceXMLPath', into a new XML according to the XSL stylesheet located in 'transformationXSLTPath'.
XSLTResponse transformXMLString(String sourceXML, String[] transformationXSLTChain)
Transforms the XML String passed as input through the 'sourceXML' parameter through a chain of XSL transformations.
XSLTResponse transformXMLString(String sourceXML, String transformationXSLTPath)
Transforms the XML passed as string input in parameter 'sourceXML' into a new XML according to the XSL stylesheet located in 'transformationXSLTPath'.
XSLTResponse transformXMLStringFromXSLT(String sourceXML, String transformationXSLTCode)
Transforms the XML passed as string input in parameter 'sourceXML' into a new XML according to the XSL stylesheet located in 'transformationXSLTPath'.
String transformer(String sourceType, String destinationType, String sourceXML, String mapperURL)
Looks up the stylesheet (or chain of) that maps the Source Type XML schema to the Destination Type.
String validateXSLT(String transformationXSLTCode)
Validates the XSLT passed as input Validation message is passed as output
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private TransformerMessageReceiver messages

private TransformerErrorListener warnings_errors

Public Constructors

public XMLStylesheetTransformer ()

Constructor

Public Methods

public String getValidationMessage ()

Returns
  • the messages

public TransformerErrorListener getWarnings_errors ()

Returns
  • the warnings_errors

public String transformFiles (String sourceXMLPath, String transformationXSLTPath, String destinationXMLPath)

Transforms the XML within the file identified through parameter 'souceXMLPath', into a new XML according to the XSL stylesheet located in 'transformationXSLTPath'. The outputted XML is stored in the file located through 'destinationXMLPath'.

Parameters
sourceXMLPath URI of file where the source XML is located
transformationXSLTPath URI of file where the XSL Stylesheet is located
destinationXMLPath URI of file where the transformed XML is stored
Returns
  • Transformed XML as string
Throws
TransformerException
TransformerConfigurationException

public XSLTResponse transformXMLString (String sourceXML, String[] transformationXSLTChain)

Transforms the XML String passed as input through the 'sourceXML' parameter through a chain of XSL transformations. The array of XSL Stylesheets identified through parameter 'transformationXSLTChain' are executed in sequence such that, starting from 'sourceXML', each subsequence stylesheet transforms the XML outputted from the previous transformation. Transformer chaining had to be implemented to cater for cases when XML is embedded within XML using the CDATA structure.

Parameters
sourceXML XML String to transform
transformationXSLTChain Array of stylesheets to sequentially use to transform 'sourceXML'
Returns
  • Transformed XML String
Throws
IOException
FileNotFoundException
TransformerConfigurationException
TransformerException

public XSLTResponse transformXMLString (String sourceXML, String transformationXSLTPath)

Transforms the XML passed as string input in parameter 'sourceXML' into a new XML according to the XSL stylesheet located in 'transformationXSLTPath'. The transformed XML is passed as output

Parameters
sourceXML XML String to transform
transformationXSLTPath URI of file where the XSL Stylesheet is located
Returns
  • Transformed XML String
Throws
TransformerException
TransformerConfigurationException

public XSLTResponse transformXMLStringFromXSLT (String sourceXML, String transformationXSLTCode)

Transforms the XML passed as string input in parameter 'sourceXML' into a new XML according to the XSL stylesheet located in 'transformationXSLTPath'. The transformed XML is passed as output

Parameters
sourceXML XML String to transform
transformationXSLTCode The XSL Stylesheet code
Returns
  • Transformed XML String
Throws
TransformerException
TransformerConfigurationException

public String transformer (String sourceType, String destinationType, String sourceXML, String mapperURL)

Looks up the stylesheet (or chain of) that maps the Source Type XML schema to the Destination Type. These are located within the wsmapper.xml file.

Parameters
sourceType Identifies the schema of the source XML
destinationType Identifies the schema expected in the destination XML
sourceXML The XML string in the source schema
mapperURL
Returns
  • The XML string in the destination schema
Throws
FileNotFoundException
IOException
ParserConfigurationException
SAXException
TransformerConfigurationException
TransformerException
XPathExpressionException

public String validateXSLT (String transformationXSLTCode)

Validates the XSLT passed as input Validation message is passed as output

Parameters
transformationXSLTCode The XSL Stylesheet code
Returns
  • XSLT Compilation message
Throws
TransformerException
TransformerConfigurationException