I am working with j2re1.4.2_12 and xslt 1.0.
I am trying to create elements to be printed by the front end. I have a need to be aware of the previous medication priority in the druglist while working with the current list so the worksheet can be generated correctly.
Here is my
java code:
(this code is not correct and is giving me an error of previousDrugList1 cannot be resolved on previousmedicationpriority.
The error is at this statement: previousmedicationpriority.appendChild(xmlDoc.createTextNode(previousDrugList1.medicationPriority)); )
I have looked for xslt functions that might be able to help but I did not find any. I then assumed that I needed to create a solution in the middle tier and pass it to the presentation tier.
void generateDrugElements(Element element, Document xmlDoc)
{
if(drugList != null)
{
for(int i=0;i<drugList.size();i++)
{
RxDbDrugRecord drugList1 = (RxDbDrugRecord) drugList.get(i);
if (i==0)
{
RxDbDrugRecord previousDrugList1 = (RxDbDrugRecord) drugList.get(i);
}
else
{
RxDbDrugRecord previousDrugList1 = (RxDbDrugRecord) drugList.get(i-1);
}
Element drug = xmlDoc.createElement("drug");
element.appendChild(drug);
Element filldate = xmlDoc.createElement("filldate");
filldate.appendChild(xmlDoc.createTextNode(drugList1.fillDate));
drug.appendChild(filldate);
Element drugname = xmlDoc.createElement("drugname");
drugname.appendChild(xmlDoc.createTextNode(drugList1.drugName));
drug.appendChild(drugname);
Element genericname = xmlDoc.createElement("genericname");
genericname.appendChild(xmlDoc.createTextNode(drugList1.genericName));
drug.appendChild(genericname);
Element medicationpriority = xmlDoc.createElement("medicationpriority");
medicationpriority.appendChild(xmlDoc.createTextNode(drugList1.medicationPriority));
drug.appendChild(medicationpriority);
if (i==0)
{
Element previousmedicationpriority = xmlDoc.createElement("lastmedicationpriority");
previousmedicationpriority.appendChild(xmlDoc.createTextNode(""));
drug.appendChild(previousmedicationpriority);
}
else
{
Element previousmedicationpriority = xmlDoc.createElement("lastmedicationpriority");
previousmedicationpriority.appendChild(xmlDoc.createTextNode(previousDrugList1.medicationPriority));
drug.appendChild(previousmedicationpriority);
}
Element druggroup = xmlDoc.createElement("druggroup");
druggroup.appendChild(xmlDoc.createTextNode(drugList1.drugGroup));
drug.appendChild(druggroup);
}
}
} //generateDrugElements