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

RE: XML, XST, and Javascript

Subject: RE: XML, XST, and Javascript
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Thu, 18 Nov 2004 10:44:12 +0200
span onload
Hi,

> 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

Why?

> =================================================================
> 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>

If you want to use extensions written in Javascript, you have to declare them as such. Right now you're just generating a Javascript block into you result tree. See your XSLT processors documentation on how to use extensions written in Javascript.
 
>        <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>

This is ill-formed XML. Again, check the documentation how to call extensions, I quess something in the lines of

  <span onload="{percent(max-percent)}" />

or just use XPath

  <span onload="{percent(max-percent * 100)}" />

Cheers,

Jarno

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.