I know there wasn't a fourm for this but everyone here seems to know so much. I got a project due tommorow and the requirement of it is that we need an XSLT style sheet with computational ability. I really don't get this whole thing and find the use of XML pointless but thats a different argument for another time
here's my code
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0"/>
<xsl:template match="/">
<html>
<head>
<title>Doctors Without Borders: Your Order Sheet</title>
</head>
<body>
<table class="orderSheet" width="200" border="2" cellpadding="2">
<tr>
<th colspan="2" bgcolor="white">Order Summery </th>
</tr>
<tr>
<th class="orderSheet">Orders</th>
<td class="orderSheet" width="50">
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="moreinfo">
<table class="orderinfo" border="10" cellpadding="2">
<tr>
<th class="orderinfo">Total Price </th>
<td class="orderinfo"><xsl:value-of select="sum(package/itemA/itemB/itemC/itemD/@price)"/></td>
</tr>
<tr>
<th class="grand" colspan="3">Grand Total</th>
<td class="grand"><xsl:value-of select="sum(order/items/item/@qty)"/></td>
<td class="grand"></td>
<td class="grand"></td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
I want it to simply calculate the total of the price variable in this XML sheet, which is under the element package which is a child of moreInfo.
heres my XML Document (*note has an internal DTD)
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!DOCTYPE html
[
<!-- Add more stuff here!! -->
<!ELEMENT html (donation,donate,featuredDonator)>
<!ELEMENT donate (header,prompt,firstName,lastName,address,paymentMethod,moreInfo)>
<!ELEMENT header (#PCDATA)>
<!ELEMENT prompt (#PCDATA)>
<!ELEMENT firstName (#PCDATA)>
<!ELEMENT lastName (#PCDATA)>
<!ELEMENT address (city,state)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT state (#PCDATA)>
<!ELEMENT paymentMethod (#PCDATA)>
<!ELEMENT moreInfo (p+,package)>
<!ELEMENT p (#PCDATA)>
<!ELEMENT package (itemA?,itemB?,itemC?,itemD?)>
<!ELEMENT itemA (#PCDATA)>
<!ELEMENT itemB (#PCDATA)>
<!ELEMENT itemC (#PCDATA)>
<!ELEMENT itemD (#PCDATA)>
<!ATTLIST itemA price CDATA #REQUIRED>
<!ATTLIST itemB price CDATA #REQUIRED>
<!ATTLIST itemC price CDATA #REQUIRED>
<!ATTLIST itemD price CDATA #REQUIRED>
<!ELEMENT featuredDonator (img,name,location,bio)>
<!ELEMENT img (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT location (#PCDATA)>
<!ELEMENT bio (#PCDATA)>
]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Doctors Without Borders-Donation Page</title>
<link rel="stylesheet" type="text/css" href="donation.css "/>
</head>
<body>
<table style="width: 100%">
<tr>
<td colspan="2"><img align="center" height="245" src="file:///C:/Users/Rob/Documents/websitedev/final%20Project/images/navbar.jpeg" width="914" /> </td>
</tr>
<tr>
<td rowspan="3" style="width: 132px"><img float="left" align="top" height= "728" src="file:///C:/Users/Rob/Documents/websitedev/final%20Project/images/sidebar.jpeg" width="193"/></td>
<td>
<donation>
<donate>
<header> DONATION PAGE</header>
<promp>You are taking the begining steps to helping those in need arround the world and becoming a part of a great cause!
Please take some time to follow the following prompts and fill out the required information. Then take some time to read up on
our featured donator!
</promp>
<firstName> First Name: <input name="First" type="text"/><form method="post"> </form> </firstName>
<lastName> Last Name: <input name="Last" type="text"/><form method="post"> </form> </lastName>
<address> Address: <input name="Address" type="text"/><form method="post"></form> </address>
<city>City: <input name="City" type="text"/><form method="post"></form></city>
<state>State: <input name="State" type="text"/><form method="post"></form></state>
<paymentMethod> <form method="post">
<select name="PaymentChoice">
<option>Payment Choice</option>
<option>American Express</option>
<option>Discover</option>
<option>Debit</option>
<option>MasterCard</option>
<option>Visa</option>
</select>
</form>
</paymentMethod>
<!--make a dropdown menu-->
<moreInfo>
<p>What made you want to donate?
<form method="post">
<textarea cols="20" name="TextArea1" rows="2"></textarea></form>
</p>
<p>Tell us a little bit about yourself
<form method="post">
<textarea cols="20" name="TextArea1" rows="2"></textarea></form>
</p>
<package>
<itemA price="10.00"> Offical MSF Donator Shirt </itemA>
<itemB price ="8.00"> Offical MSF Donator Hat </itemB>
<itemC price="5.00">Offical MSF Donator Card </itemC>
<itemD price="15.00">MSF: Make a Difference doucmentary DVD</itemD>
</package>
</moreInfo>
</donate>
<featuredDonator>
<img><img float="left" src="file:///C:/Users/Rob/Documents/websitedev/final%20Project/images/imgerz.jpg " /> </img>
<name> Corrine Touchebacher </name>
<location> Peetree,Oregan </location>
<bio> I Love helping people less fortunate then me, my entire
family has been doing it for generations </bio>
</featuredDonator>
</donation>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
Sorry if the code tags aren't right im still trying to get the hang of this
<--- MEGA NOOB