[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XML, XST, and Javascript

Subject: XML, XST, and Javascript
From: ケンジイ ムヤモト <kenjii.muyamoto@xxxxxxxxx>
Date: Wed, 17 Nov 2004 17:45:08 -0800
xml xst
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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.