Hello,
I'm trying to get a weight chart done in XML, just for practice. To
help with the % and weight, I'll need to calculate multiplication.
Javascript seemed the logical way, but I can't figure out how to send
an XML element as an agrument for a Javascript function. Could
someone help?
Here's my current source:
=================================================================
XML:
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="weight-chart-style.xsl" ?>
<!DOCTYPE chart [
<!ELEMENT chart (chart-head, chart-data) >
<!ELEMENT chart-head (title, max-total) >
<!ELEMENT title (CDATA) >
<!ELEMENT max-total (CDATA) >
<!ELEMENT chart-data (exercise) >
<!ELEMENT exercise (muscles, max-percent, reps) >
<!ATTLIST exercise title CDATA #REQUIRED >
<!ELEMENT muscles (PCDATA) >
<!ELEMENT max-percent (CDATA) >
<!ELEMENT reps (CDATA) >
]>
<chart>
<chart-head>
<chart-title>Weight-Lifting Chart</chart-title>
</chart-head>
<chart-data>
<exercise title="Exercise">
<muscles>Muscles</muscles>
<max-percent>80%</max-percent>
<reps>8</reps>
</exercise>
<exercise title="Exercise">
<muscles>Muscles</muscles>
<max-percent>90%</max-percent>
<reps>4</reps>
</exercise>
</chart-data>
</chart>
=================================================================
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<script type="text/javascript">
<!--
function percent(pom) {
var max = 100;
return pom * max;
}
//-->
</script>
<title>Weight Chart</title>
</head>
<body>
<xsl:for-each select="chart/chart-head">
<h1><xsl:value-of select="chart-title" /></h1>
</xsl:for-each>
<xsl:for-each select="chart/chart-data">
<table>
<tr>
<th>Exercise</th>
<th>Muscles</th>
<th>Max %</th>
<th>Weight</th>
<th>Reps</th>
</tr>
<xsl:for-each select="exercise">
<tr>
<td><xsl:value-of select="@title" /></td>
<td><xsl:value-of select="muscles" /></td>
<td><xsl:value-of select="max-percent" /></td>
<td><span onload="percent(<xsl:value-of
select="max-percent">)" /> Lbs.</td>
<td>____ / <xsl:value-of select="reps" /></td>
</tr>
</xsl:for-each>
</table>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--