Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To embed JavaScript for the aid of transformation you can use &lt;xsl:script&gt;, but <a href="http://www.topxml.com/xsl/tutorials/intro/xsl10.asp" rel="nofollow noreferrer">it is limited</a> to Microsoft's XML objects implementation. Here's an <a href="https://oxampleski.googlecode.com/svn/trunk/XSL" rel="nofollow noreferrer">example</a>:</p> <p><strong>scripted.xml</strong>:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;?xml-stylesheet type="text/xsl" href="scripted.xsl"?&gt; &lt;data a="v"&gt; ding dong &lt;/data&gt; </code></pre> <p><strong>scripted.xsl</strong>:</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;html xmlns:xsl="http://www.w3.org/TR/WD-xsl"&gt; &lt;xsl:script implements-prefix="local" language="JScript"&gt;&lt;![CDATA[ function Title() { return "Scripted"; } function Body(text) { return "/" + text + "/"; } ]]&gt;&lt;/xsl:script&gt; &lt;head&gt; &lt;title&gt;&lt;xsl:eval&gt;Title()&lt;/xsl:eval&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;xsl:for-each select="/data"&gt;&lt;xsl:eval&gt;Body(nodeTypedValue)&lt;/xsl:eval&gt;&lt;/xsl:for-each&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The result in Internet Explorer (or if you just use MSXML from COM/.NET) is:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Scripted&lt;/titlte&gt; &lt;/head&gt; &lt;body&gt; /ding dong/ &lt;/body&gt; &lt;/html&gt; </code></pre> <p>It doesn't appear to support the usual XSL template constructs and adding the root node causes MSXML to go into some sort of standards mode where it won't work.</p> <p>I'm not sure if there's any equivalent functionality in standard XSL, but I can dream.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload