title: Passing node as parameter in msxsl:script javascript function from XSLT for-each doesn't work
body: <p>I am using MSXML6 and I've set the AllowXsltScript to true in order to enable the usage of scripts in my VB program.</p>
  <p>Given the following XML input:</p>
  <pre><code>&lt;xml&gt;
      &lt;data&gt;
          &lt;row TEST_ATTRIBUTE_1=&quot;test1a&quot; TEST_ATTRIBUTE_2=&quot;test2a&quot;/&gt;
          &lt;row TEST_ATTRIBUTE_1=&quot;test1b&quot; TEST_ATTRIBUTE_2=&quot;test2b&quot;/&gt;
          &lt;row TEST_ATTRIBUTE_1=&quot;test1c&quot; TEST_ATTRIBUTE_2=&quot;test2c&quot;/&gt;
      &lt;/data&gt;
  &lt;/xml&gt;
  </code></pre>
  <p>The following XSL doesn't work as expected:</p>
  <pre><code>&lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;  version = &quot;1.0&quot;
    xmlns:rs=&quot;urn:schemas-microsoft-com:rowset&quot; xmlns:z=&quot;#RowsetSchema&quot;
    xmlns:msxsl=&quot;urn:schemas-microsoft-com:xslt&quot;
    xmlns:user=&quot;random&quot;&gt;
  
    &lt;msxsl:script language=&quot;javascript&quot; implements-prefix=&quot;user&quot; &gt;
    &lt;![CDATA[
    function getValue(node, attribute)
    {  
       var value;
       value = node.getAttribute(attribute);
  
       return value;
    }
   ]]&gt;
    &lt;/msxsl:script&gt;
    
    &lt;xsl:template match=&quot;/&quot;&gt;
      &lt;xsl:apply-templates select=&quot;//data&quot;/&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match=&quot;//data&quot;&gt;
      &lt;TBODY&gt;
        &lt;xsl:for-each select=&quot;row&quot;&gt;
          &lt;xsl:value-of select=&quot;user:getValue(this, 'TEST_ATTRIBUTE_1')&quot;/&gt;
        &lt;/xsl:for-each&gt;
      &lt;/TBODY&gt;
    &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  <p>The problem seems to be with passing in &quot;this&quot; for node inside for-each. More exactly when it's trying to do <code>node.getAttribute(attribute);</code> that's when it fails.</p>
  <p>The error I'm getting is &quot;The text associated with this error code could not be found. XML document must have a top level element.&quot; inside Visual Studio 2017 in my VB program using the MSXML2.DOMDocument60.transformNodeToObject API.</p>
  <p>Note that I cannot use any online XSL parsers as they have the script functionality disabled by default.</p>
  <p>Any thoughts on this?</p>
  <p>Appreciate it!</p>