File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes creating elements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "creating elements" Watch "creating elements" New topic
Author

creating elements

joseph cooper
Ranch Hand

Joined: Nov 08, 2005
Posts: 44
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
joseph cooper
Ranch Hand

Joined: Nov 08, 2005
Posts: 44
The xml might of been helpfull to follow my logic eaiser.

- <drug>
<filldate>03/2008</filldate>
<drugname>Coumadin</drugname>
<genericname>WARFARIN</genericname>
<medicationpriority>HIGH</medicationpriority>
<lastmedicationpriority></lastmedicationpriority>
</drug>
- <drug>
<filldate>04/2008</filldate>
<drugname>Coumadin</drugname>
<genericname>WARFARIN</genericname>
<medicationpriority>HIGH</medicationpriority>
<lastmedicationpriority>HIGH</lastmedicationpriority>
</drug>
- <drug>
<filldate>04/2008</filldate>
<drugname>Calan</drugname>
<genericname>VERAPMIL</genericname>
<medicationpriority>MEDIUM</medicationpriority>
<lastmedicationpriority>HIGH</lastmedicationpriority>
</drug>
- <drug>
<filldate>04/2008</filldate>
<drugname>Calan</drugname>
<genericname>VERAPMIL</genericname>
<medicationpriority>MEDIUM</medicationpriority>
<lastmedicationpriority>MEDIUM</lastmedicationpriority>
</drug>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating elements