Namespace Prefixes in XSLT
The following are some commonly used namespace prefixes in an XSLT style sheet.
<?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns="urn:schemas-mycompany-com:xslt" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:fo="http://www.w3.org/1999/XSL/Format">
In addition, user-defined namespace prefixes might be needed. For example, if you use <msxsl:script>
to implement an extension function for an XPath expression, you must specify a namespace prefix to be used with the extension function. Suppose you implemented the following doSomething
function.
<msxsl:script language="JScript" implements-prefix="user"> function doSomething(nodeset) { // result = something about the nodeset return result; } </msxsl:script>
You could use it in a template rule, as follows:
<xsl:value-of select="user:doSomething(.)"/>
You would have to add the user namespace declaration to the <xsl:stylesheet>
element:
xmlns:user="http://mycompany.com/mynamespace"
Note It is recommended that you use the default namespace for literal result elements, such as <HTML> and <H2>.
See Also
Working with Namespaces and Prefix Aliases | Declaring the msxsl: Namespace Prefix