M_K
M_K

Reputation: 3455

Is it possible to create a xsl variable from javascript?

<xsl:variable name="delivery">
   <script language="javascript" type="text/javascript"> document.getElementById('id').value;</script>
</xsl:variable>

Is it possible to create a xsl variable from javascript like the example above?

Upvotes: 0

Views: 362

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167571

No, XSLT transformation happens first, then in a second, separate step a browser might render the transformation result containing some script code and execute the script as well. So with your sample

<xsl:variable name="delivery">
   <script language="javascript" type="text/javascript"> document.getElementById('id').value;</script>
</xsl:variable>

during XSLT transformation the value of the delivery variable is a result tree fragment containing a script element node containing a text node (which happens to be client-side Javascript code), but no script execution happens during the XSLT transformation.

Upvotes: 1

Related Questions