Subject: RE: Contents of a <div> into an AVT?
From: Américo Albuquerque <melinor@xxxxxxx>
Date: Thu, 7 Aug 2003 01:13:01 +0100
|
Hi.
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Kathy Burke
> Sent: Wednesday, August 06, 2003 7:14 PM
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: RE: Contents of a <div> into an AVT?
>
>
> Sorry, I didn't provide that info. For this xml element:
>
> <step>This is the first step.</step>
>
>
> My template does the following:
>
> (1) Creates an html table structure.
>
> (2) In the first column, creates a button with an onclick
> event (which requires use of variables to pass querystring).
>
> (3) Second column, apply xsl:number to the <step> which gives me:
> 1. This is the first step.
>
> That onclick event for each <step>'s button needs the two
> variables ('the number', 'the text of the step'). I capture
> the 2nd var using {.}. but can't figure out how to get the
> "number" (1.2, 1.3, etc.).
>
> ***********************
>
> If I may, here is the template for the step...the entire xsl
> is rather long.
>
> <xsl:template match="step">
> <table>
> <tr>
> <td align="center" valign="middle">
>
> <input type="button" value="Anomaly"
> onclick="Javascript:Anomaly('{id}','{.}')"></input>
>
> </td>
> <td>
> <xsl:variable name="id">
>
> <xsl:number level="multiple" count="step" format="1.1"/>
> </xsl:variable>
>
> <div id="Step_{$id}">
> <xsl:value-of select="$id"/>
> </div>
This is a mixed issue, half javascript half xslt :)
First the javascript part:
If you have you id=Step_1.2, javascript will treat this as property '2' of
object 'Step_1'. so you'll have to change your id definition
The xslt part:
You define your <input> in the same way you define your <div>
<input .... Onclick="Javascript:Anomaly('{$id}','{.}')">
For this to work the definition of the variable id must be the first chilf
of <xsl:template>
So you'll need to have something like:
<xsl:template match="step">
<xsl:variable name="id"><xsl:number level="multiple" count="step"
format="1.1"/></xsl:variable>
<table>
<tr>
<td align="center" valign="middle">
<input type="button" value="Anomaly"
onclick="Javascript:Anomaly('{$id}','{.}')"></input>
</td>
<td>
<div id="Step_{$id}">
<xsl:value-of select="$id"/>
</div>
<xsl:apply-templates select="step"/>
</td>
</tr>
</table>
</xsl:template>
For the id I would use generate-id() instead, like:
<xsl:template match="step">
<table>
<tr>
<td align="center" valign="middle">
<input type="button" value="Anomaly"
onclick="Javascript:Anomaly('{generate-id()}','{.}')"></input>
</td>
<td>
<div id="{generate-id()}">
<xsl:number level="multiple" count="step" format="1.1"/>
</div>
<xsl:apply-templates select="step"/>
</td>
</tr>
</table>
</xsl:template>
(...)
Hope this helps you
Regards,
Americo Albuquerque
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|