Hi,
I was using dom4j. Here is an example how i created Document:
public Document createTestCaseDocument() {
Map symbol_values = AIMT_DB.loadSymbols(planInfo.getCategory());
Document testCaseDocument = DocumentHelper.createDocument();
Element testCaseEle = testCaseDocument.addElement(TEST_CASE_ELE)
.addAttribute(CUSTOMER_ID_ATTR, ""+planInfo.getCustomerID())
.addAttribute(CUSTOMER_NAME_ATTR, planInfo.getCustomerName())
.addAttribute(IVR_ID_ATTR, ""+planInfo.getCategory())
.addAttribute(IVR_NAME_ATTR, planInfo.getCategoryName())
.addAttribute(ID_ATTR, ""+planInfo.getPlanId())
.addAttribute(NAME_ATTR, planInfo.getName())
.addAttribute(AUTHOR_ATTR, planInfo.getAuthor())
.addAttribute(LAST_MODIFIED_ATTR, ""+planInfo.getLastModified())
.addAttribute(IVR_NUMBER_PREFIX_ATTR, planInfo.getIVRNumberPrefix())
.addAttribute(IVR_NUMBER_ATTR, planInfo.getIVRNumber())
.addAttribute(INSTANCES_ATTR, ""+planInfo.getInstances())
.addAttribute(SENSITIVITY_ATTR, ""+planInfo.getSensitivity())
.addAttribute(ALLOWBARGEIN_ATTR, planInfo.isAllowBargein() ? "true" : "false")
.addAttribute(CALLERID_ATTR, planInfo.getCallerID());
//other code here
return testCaseDocument;
}
Use the following functions and xsl file to create my presentation data:
public String outputXML(Document document) {
return document.asXML();
}
public Document styleDocument(
Document document,
String stylesheet)
throws Exception {
// load the transformer using JAXP
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(
new StreamSource( stylesheet )
);
// now lets style the given document
DocumentSource source = new DocumentSource( document );
DocumentResult result = new DocumentResult();
transformer.transform( source, result );
// return the transformed document
Document transformedDoc = result.getDocument();
return transformedDoc;
}
Cheers
Chris