|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| 09/11/2009 at 08:42AM PDT, ID: 24724925 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: |
// import statements
<%@ page import= "java.io.File"%>
<%@ page import= "java.io.FileOutputStream"%>
<%@ page import= "java.io.IOException"%>
<%@ page import= "javax.xml.parsers.DocumentBuilder"%>
<%@ page import= "javax.xml.parsers.DocumentBuilderFactory"%>
<%@ page import= "javax.xml.parsers.ParserConfigurationException"%>
<%@ page import= "javax.xml.transform.OutputKeys"%>
<%@ page import= "javax.xml.transform.Transformer"%>
<%@ page import= "javax.xml.transform.TransformerConfigurationException"%>
<%@ page import= "javax.xml.transform.TransformerException"%>
<%@ page import= "javax.xml.transform.TransformerFactory"%>
<%@ page import= "javax.xml.transform.dom.DOMSource"%>
<%@ page import= "javax.xml.transform.stream.StreamResult"%>
<%@ page import= "org.w3c.dom.Document"%>
<%@ page import= "org.w3c.dom.Element"%>
<%@ page import= "org.w3c.dom.Node"%>
<%@ page import= "org.w3c.dom.NodeList"%>
//code to write xml file
try{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
Element rootElement = document.createElement("DashbUnit");
rootElement.setAttribute("id",dbUnitId);
document.appendChild(rootElement);
for(int i=0;i<counter;i++){
Element setElement1 = document.createElement("Param");
setElement1.setAttribute("name",parNames[i]);
setElement1.setAttribute("value",parVals[i]);
rootElement.appendChild(setElement1);
}
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
//Add indentation to output
transformer.setOutputProperty
(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(
"{http://xml.apache.org/xslt}indent-amount", "2");
DOMSource source = new DOMSource(document);
FileOutputStream output = new FileOutputStream(new File(fPathParVal));
StreamResult result = new StreamResult(output);
transformer.transform(source, result);
System.out.println("file transfered");
output.flush();
output.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());
}
|
Advertisement