Microsoft XML 2.5 SDK


 

msxsl:script Element

[This is preliminary documentation and subject to change.]

Appears at the top level of the style sheet and contains script blocks which define global variables and functions for script extensions.

Can only be recognized by style sheets that use the built-in extension namespace urn:schemas-microsoft-com:xslt.

Syntax

<msxsl:script

    language="language-name"

    implements-namespace="prefix of user's namespace"  >

</msxsl:script>

Attributes

language

Active Scripting language used for the functions defined within this element. If left unspecified, the current scripting language is used, as specified by a language attribute on an ancestor. If no such attribute exists, JScript® (compatible with ECMA 262 language specification) is used. This attribute accepts the same values as the language attribute on the HTML SCRIPT element.

Implements-namespace

Declares a namespace and associates it with one or more script blocks. The value of this attribute is the prefix which represents the namespace. As with all uses of prefixes, the actual matching of a function call to a script block is performed on the namespace URI, so the function call may have a different prefix in scope than the script block.

Element Information

Number of occurrences Unlimited
Parent elements xsl:stylesheet
Child elements (No child elements)
Requires closing tag Yes. XSLT is an XML grammar and, like all XML grammars, all tags must have closing tags to satisfy the definition of well-formed.

Remarks

You can declare variables and define functions within the msxsl:script element. This can appear within the xsl:stylesheet or xsl:template elements. A script block thus nested is treated as a global script block.

In Internet Explorer version 5.01, you can also instantiate COM objects in the msxsl:script element. However, a user's security settings may prevent your script from instantiating a client-side object.

Example

This example

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                xmlns:user="http://mycompany.com/mynamespace">
  <msxsl:script language="JScript" implements-prefix="user">
    function xml(nodelist) {
      return nodelist.nextNode().xml;
    }
  </msxsl:script>
  
  <xsl:template match="/">
    <xsl:value-of select="user:xml(.)"/>
  </xsl:template>
</xsl:stylesheet>

See Also

xsl:script