Thanks for reviewing my question.
I working with saxon java api as XSLT processor. Getting difficulty to catch the exception return by saxon jar file.
I am able to print the javax exception. But need to get the exception in string returned by saxon.
Below function i am using to transform the xml:
import java.io.File;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public class Main {
/**
* Simple transformation method.
* @param sourcePath - Absolute path to source xml file.
* @param xsltPath - Absolute path to xslt file.
* @param resultDir - Directory where you want to put resulting files.
*/
public static void simpleTransform(String sourcePath, String xsltPath,
String resultDir) {
TransformerFactory tFactory = TransformerFactory.newInstance();
try {
Transformer transformer =
tFactory.newTransformer(new StreamSource(new File(xsltPath)));
transformer.transform(new StreamSource(new File(sourcePath)),
new StreamResult(new File(resultDir)));
} catch (Exception e) {
e.message();
}
}
public static void main(String[] args) {
//Set saxon as transformer.
System.setProperty("javax.xml.transform.TransformerFactory",
"net.sf.saxon.TransformerFactoryImpl");
simpleTransform("d:/project/hob/AppModule.xml",
"d:/project/hob/create-fragment.xslt", "C:/");
}
}
Could you guys suggest to get the saxon exception into the string. Below is the example of exception returned saxon jar file.
SXJE0008: cannot convert xs:yearMonthDuration to the required Java type
Thanks, Deepak