}
public Document applyRender() throws ParserConfigurationException, JIException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
String ns = XMLConstants.IPC_NS;
OCDocumentMetadataObject metadata = documentObject.getMetadata();
DocumentBuilder db = dbf.newDocumentBuilder();
// create an instance of DOM
Document doc = db.newDocument();
// create root element
String docTypeName = metadata.getName();
Element root = doc.createElementNS(ns, XMLConstants.DOC_OBJ_PREF);
root.setAttribute("name", docTypeName);
if (showRootGUID) {
root.setAttribute("guid", documentObject.getRef()
.getUUID().toString());
}
// create number element
Element number = doc.createElementNS(ns, "Number");
number.setTextContent(documentObject.getNumberAsString());
root.appendChild(number);
// create date element
Element date = doc.createElementNS(ns, "Date");
date.setTextContent(sdFormat.format(documentObject.getDate()));
root.appendChild(date);
// create isPosted
Element isPosted = doc.createElementNS(ns, "Posted");
isPosted.setTextContent(String.valueOf(documentObject.isPosted()));
root.appendChild(isPosted);
// create isDeleted
Element isDeleted = doc.createElementNS(ns, "DeletionMark");
isDeleted.setTextContent(String.valueOf(documentObject.isDeletionMark()));
root.appendChild(isDeleted);
// create attribute elements
Element attrElement = doc.createElementNS(ns, "Attributes");
root.appendChild(attrElement);
OCMetadataAttributeCollection attributeMetaCollection = metadata.getAttributes();
OCAttributeMetadataObject amoTmp = null;
int amcSZ = attributeMetaCollection.size();
for (int z = 0; z < amcSZ; z++) {
amoTmp = attributeMetaCollection.get(z);
String oName = amoTmp.getName();
//String tName = transliterate(oName);
Element elem = doc.createElementNS(ns, "Attribute");
elem.setAttribute("name", oName);
OCVariant var = documentObject.getAttributeValue(oName);
Object varValue = var.value();
int typeCode = var.getTypeCode();
boolean isRef = (typeCode > 99);
Object attrVal = documentObject.getAttributeValue(oName).value();
//handle different type of types
if (attrVal instanceof Date) {
attrVal = sdFormat.format(attrVal);
}
elem.setTextContent(attrVal.toString());
if (showIsRefAttribute) {
elem.setAttribute("isRef", String.valueOf(isRef));
}
if (isRef) {
if (showRefType && varValue instanceof _OCCommonRef) {
elem.setAttribute("refType", ((_OCCommonRef) varValue).getMetadata().getFullName());
} else
if (showRefType && varValue instanceof OCEnumRef ) {
elem.setAttribute("refType", ((OCEnumRef) varValue).getMetadata().getFullName());
}
if (showRefGUID && varValue instanceof _OCCommonRef) {
elem.setAttribute("guid", ((_OCCommonRef) varValue).getUUID().toString());
}
}
attrElement.appendChild(elem);
}
// create table section
Element tabSections = doc.createElementNS(ns, "TabularSections");
root.appendChild(tabSections);
OCMetadataTabularSectionCollection tabSecCollection = metadata.getTabularSections();
int tabSecColSZ = tabSecCollection.size();
for (int z = 0; z < tabSecColSZ; z++) {
OCTabularSectionMetadataObject tsmO = tabSecCollection.get(z);
OCMetadataAttributeCollection tsAttrMetadata = tsmO.getAttributes();
String tabSecName = tsmO.getName();