I am trying to transform an XML by invoking an XSLT from my java code. I am facing an issue in passing a XML string as parameter to the XSLT. This causes an exception: Invalid conversion from 'java.lang.String' to 'node-set'.
This is the method to invoke the XSLT:
Transformer l_transformer
=TransformerFactory.newInstance().newTransformer(xslt_file_path);
l_transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
l_transformer.setParameter("collateralDoc", param_xmlString);
StringWriter l_writer = new StringWriter();
StringReader l_reader = new StringReader(inputXML);
Source l_in = new StreamSource(l_reader);
Result l_out = new StreamResult(l_writer);
l_transformer.transform(l_in, l_out);
After searching for some solutions I even tried creating a Document object from the param XML string and passed the Document object to the setParameter object. Then I got this exception:
Invalid conversion from 'com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl' to 'node-set'.
The XSLT code which processes this input XML param and the line which throws the exception:
<xsl:variable name="infoList" select="$paramXML/a/b"/>
The param XML which I need to pass as param looks like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<a>
<b>
<c>
<d>blah</d>
<e>blah</e>
</c>
<f>
<g>blah</g>
<h>blah</h>
</f>
</b>
</a>
Please help me in resolving the issue.