ramadevimandala
asked on
Getting TransformerException while using JAXP to create the XML
I am getting the below exception while creating the XML file with JAXP
TransformerException XSL-1900: (Fatal Error) An internal error condition occurred.
Please help me to resolve this.
here is my code:
TransformerException XSL-1900: (Fatal Error) An internal error condition occurred.
Please help me to resolve this.
here is my code:
try{
DocumentBuilderFactory factory1 = DocumentBuilderFactory.newInstance();
DocumentBuilder builder1 = factory1.newDocumentBuilder();
Document document1 = builder1.newDocument();
Element rootElement1 = document1.createElement("DashbUnit");
rootElement1.setAttribute("id",dbUnitId);
document1.appendChild(rootElement1);
for(int i=0;i<counter;i++){
Element setElement1 = document1.createElement("Param");
setElement1.setAttribute("name",parNames[i]);
setElement1.setAttribute("value",parVals[i]);
rootElement1.appendChild(setElement1);
}
TransformerFactory tFactory1 = TransformerFactory.newInstance();
Transformer transformer1 = tFactory1.newTransformer();
//Add indentation to output
transformer1.setOutputProperty
(OutputKeys.INDENT, "yes");
transformer1.setOutputProperty(
"{http://xml.apache.org/xslt}indent-amount", "2");
DOMSource source1 = new DOMSource(document1);
FileOutputStream output1 = new FileOutputStream(new File(fPathParVal));
StreamResult result1 = new StreamResult(output1);
transformer1.transform(source1, result1);
System.out.println("file transfered");
output1.flush();
output1.close();
} catch (IOException e) {
System.out.println("IOException " + e.getMessage());
} catch (ParserConfigurationException e) {
System.out
.println("ParserConfigurationException " + e.getMessage());
} catch (TransformerConfigurationException e) {
System.out.println("TransformerConfigurationException "+ e.getMessage());
} catch (TransformerException e) {
System.out.println("TransformerException " + e.getMessage());
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER