Find below pasted the INCORRECT xml file
<?xml version = '1.0'?>
<#document-fragment><JavaBean CLASS="iom.decomp.data.task.EFMSPMTaskData"><Prope
rties><Property NAME="asr"><JavaBean CLASS="java.util.Vector"><Properties/></Jav
aBean></Property><Property NAME="asrSize">0</Property><Property NAME="eventSched
Date">01/26/2005</Property><Property NAME="eventType">CTP8</Property><Property N
AME="orderNumber">040203509</Property><Property NAME="sdiSize">0</Property><Prop
erty NAME="shopCartNumber">ISR04122029620</Property></Properties></JavaBean>
</#document-fragment>
and the code is as below,
public static DocumentFragment getAsDOM(Document
doc, ArrayList arrayList) throws IntrospectionException, InstantiationException,
IllegalAccessException {
// Create the fragment we'll return
DocumentFragment dfResult = null;
// Analyze the ArrayList
Class classOfArrayList = arrayList.getClass();
if (dfResult == null) {
dfResult = doc.createDocumentFragment();
//BeanInfo bi = Introspector.getBeanInfo(classOfBean);
//PropertyDescriptor[] pds = bi.getPropertyDescriptors();
// Add an Element indicating that this is a JavaBean.
// The element has a single attribute, which is that Element's class.
Element eBean = doc.createElement("JavaBean");
dfResult.appendChild(eBean);
eBean.setAttribute("CLASS", classOfArrayList.getName());
Element eProperties = doc.createElement("Properties");
eBean.appendChild(eProperties);
if(arrayList == null || arrayList.size()<1){
return dfResult;
}
for(int k =0; k < arrayList.size(); k++){
Object bean = arrayList.get(k);
DocumentFragment dfragment = XMLBeanWriter.getAsDOM(doc, bean);
if(dfragment != null){
Element eProperty = doc.createElement("Property");
eProperties.appendChild(eProperty);
// Create NAME attribute, add it to Property element,
// and set it to name of property
eProperty.setAttribute("NAME", "ArrayListElement");
// Append the DocumentFragment to the Property element
eProperty.appendChild(dfragment);
}
}
}
return dfResult;
}
The correct xml file is as given below,
--------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<JavaBean CLASS="iom.decomp.data.task.EFMSPMTaskData"><Properties><Property NAME
="asr"><JavaBean CLASS="java.util.Vector"><Properties/></JavaBean></Property><Pr
operty NAME="asrSize">0</Property><Property NAME="eventSchedDate">10/25/2004</Pr
operty><Property NAME="eventType">REJ</Property><Property NAME="orderNumber">040
202443</Property><Property NAME="orderStatus">Rejected</Property><Property NAME=
"sdiSize">0</Property><Property NAME="serviceRequestNumber">040202443</Property>
<Property NAME="shopCartNumber">ISR04102227829</Property></Properties>
</JavaBean>
The tag <#document-fragment> shouldn't have got appended at all.
Please help,
Thanks for your time,
-Jay.