Lincoln Mitchell wrote:
I simple need to convert this inline javascript:

<script type="text/javascript">
  function myFunction(){
  <xsl:choose>
    <xsl:when test=" $myParam='x'">
      alert('x')
    </xsl:when>
  </xsl:choose>
  }
</script>

…to an external javascript file like:

function myFunction(){
  if ($myParam='x'){
    alert('x')
  }
}

I don't think you have execution times very clear. XSLT code runs on your server at pipeline execution time, before or during page generation. Client javascript code runs in the client browser at page rendering time, after page generation and transmission. This means that whatever comes out of your pipeline must be well-formed HTML and/ or Javascript that will run on the browser, without access to any XSLT or Cocoon variables. In fact, by the time the generated HTML reaches the browser, the variables used in your XSLT won't exist anymore.

Nevertheless, it might be that what you're after is simply this:

<script type="text/javascript">
  var myParam = "<xsl:value-of select="$myParam"/>";
</script>

Notice the extra quotation marks around the value-of: this XSLT code is generating a HTML script tag containing Javascript code that, when run by the browser, will declare a global string variable called myParam. From that moment on, every piece of Javascript code run on the browser will have access to that global variable.

Also, this is generic web programming matter, not exactly related to Cocoon.


Tobia
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to