• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 479
  • Last Modified:

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:


                  
                  
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());
		}

Open in new window

0
ramadevimandala
Asked:
ramadevimandala
1 Solution
 
TomLunCommented:
I just tried your code with some fixed values for the attributes of the Param elements. I runs without problem.
So the question is what values are you passing in in the parNames and parVals arrays? And what is the value of dbUnitId?
0
 
ramadevimandalaAuthor Commented:
I think the problem with some browser or server, the issue is not coming now , thank you for your time
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now