Ok so this may be simple but I need some help. I'm new to Java/XML. I'm working on a
servlet that simply reads in an xml file and applies the transformation. The error that I'm getting is as follows
javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: java.lang.ClassCastException: org.apache.xpath.functions.FuncQname
the code is as below
// Output goes in the response stream.
PrintWriter out = response.getWriter();
try
{
String ctx = getServletContext().getRealPath("") + FS;
String DOC_XSL = "birds.xsl";
String DOC_XML = "birds.xml";
TransformerFactory tFactory = TransformerFactory.newInstance();
if(tFactory.getFeature(DOMSource.FEATURE) && tFactory.getFeature(DOMResult.FEATURE)){
DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
dFactory.setNamespaceAware(true);
DocumentBuilder db = dFactory.newDocumentBuilder();
Document xslDoc = db.parse(DOC_XSL);
Document xmlDoc = db.parse(DOC_XML);
DOMSource xslDomSource = new DOMSource(xslDoc);
xslDomSource.setSystemId("birds.xsl");
DOMSource xmlDomSource = new DOMSource(xmlDoc);
xmlDomSource.setSystemId(DOC_XML);
out.println(ctx+"<br>1<br>");
//error here
Transformer transformer = tFactory.newTransformer(xslDomSource);
out.println("after transformer creation");
transformer.transform(xmlDomSource, new StreamResult(out));
}
out.println("step4");
}
catch(javax.xml.transform.TransformerConfigurationException tce){
out.println(tce.getMessage());
out.println(tce.getCause());
}
catch (Exception e)
{
out.write(e.getMessage());
e.printStackTrace(out);
}
out.close();
}
Basically. The servlet is bombing where I've marked //error here. If anyone has an idea please help.
Thanks