[Contents] [Prev] [Next] [Index] [Report an Error]

ns Statement

You specify namespace definitions using the SLAX ns statement. This consists of the ns keyword, a prefix string, an equal sign, and a namespace Uniform Resource Identifier (URI). To define the default namespace, use only the ns keyword and a namespace URI.

ns junos = "http://www.juniper.net/junos/";

The ns statement can appear after the version statement at the beginning of the stylesheet or at the beginning of any block.

ns a = "http://example.com/1";
ns "http://example.com/global";
ns b = "http://example.com/2";

match / {
    ns c = "http://example.com/3";
    <top> {
        ns a = "http://example.com/4";
        apply-templates commit-script-input/configuration;
    }
}

When it appears at the beginning of the stylesheet, the ns statement can include either the exclude or extension keyword. The keyword instructs the parser to add the namespace prefix to the exclude-result-prefixes or extension-element-prefixes attribute.

ns exclude foo = "http://example.com/foo";
ns extension jcs = "http://xml.juniper.net/jcs";

The XSLT equivalent:

<xsl:stylesheet xmlns:foo="http://example.com/foo"
    xmlns:jcs="http://xml.juniper.net/jcs"
    exclude-result-prefixes="foo"
    extension-element-prefixes="jcs">
    <!- - ... - ->
</xsl:stylesheet>

[Contents] [Prev] [Next] [Index] [Report an Error]