Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
Appears at the top level of the style sheet and contains script blocks that define global variables and functions for script extensions.
Syntax
<msxsl:script language = " language-name" implements-prefix = "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 languageattribute on an ancestor. If no such attribute exists, Microsoft® JScript® (compatible with ECMA 262 language specification) is used. This attribute accepts the same values as the languageattribute on the HTML <SCRIPT> element.
- implements-prefix
-
[required] Declares a name space and associates it with the script block. The value of this attribute is the prefix that represents the name space.
Element Information
Number of occurrences |
Unlimited |
Parent elements |
|
Child elements |
(No child elements) |
Remarks
Belongs to the name space urn:schemas-microsoft-com:xslt. You can declare variables and define functions within the <msxsl:script> element. This can appear within the < xsl:stylesheet> element. A script block thus nested is treated as a global script block.
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 creates a script block with a namepace prefix of "user" that contains a function called "xml" that takes a node-list as an argument. Later, this function is called from the select attribute of <xsl:value-of>.
Copy Code | |
---|---|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="http://mycompany.com/mynamespace" version="1.0"> <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> |