RE: RE: [xsl] Need to use generate-id() or other method?

Subject: RE: RE: [xsl] Need to use generate-id() or other method?
From: cknell@xxxxxxxxxx
Date: Thu, 24 Apr 2003 11:32:29 -0500
> -----Original Message-----
> From:     "Kathy Burke" <Kathy_Burke@xxxxxxxxx>
> 
> how would I then refer to the @StartTime
> and @EndTime for any given step not knowing what the generated id
> actually is?
> 

I think you are making this more complicated than it has to be. I wouldn't recommend generate-id()here. Would it be too big an assumption to postulate that each step is known when you do the XSL transformation? That is to say, that the whole process consists of a set of known steps.

If that is true, you can add an "id" attribute for each start and stop button when you do the transformation. Say that step one is "Run to the corner and back" and that your XSL transform produces a button to be clicked when the user dashes away from the keyboard and a second button to be clicked when he or she gets back from the corner.

Further, let's say that your XML element which represents the "Run to the corner and back" step looks like this:

<step id="step-1">Run to the corner and back</step>

Your template would be along these lines:

<xsl:template match="step">
  <input type="button" value="Start" onclick="StopWatch()">
    <xsl:attribute name="id">start-<xsl:value-of select="@id" /></xsl:attribute>
  </input>
  <input type="button" value="Stop" onclick="StopWatch()">
    <xsl:attribute name="id">stop-<xsl:value-of select="@id" /></xsl:attribute>
  </input>
</xsl:template>

In your output you will now have two input elements with id attributes of "start-step-1" and "stop-step-1". In your StopWatch() function, you get the value of event.srcElement.getAttribute("id") and you know which button click raised the event, you then access your timer function to get the current time, and you have the identity of the step and the start time or the stop time, depending on which button was clicked.
-- 
Charles Knell
cknell@xxxxxxxxxx - email


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread