• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

creating elements

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic