The shell maintains a set of active globally declared namespaces. The scope of the namespaces is the same as environment variables.
The syntax and meaning is similar to the xquery "declare namespace" command (except that the uri need not be quoted).

Declared namespaces interact with the builtin <[ ]> syntax as well as the xpath and xquery commands. The xslt command does not support global namespace declarations because the xslt specs do not provide for external namespace declarations, rather all namespaces must be part of the xslt document.

All global namespaces are pre-declared for these commands.

A Namespace can be declared using the syntax
declare namespace prefix=uri

And the list of currently active namespaces can be retrieved with
declare namespace

$ declare namespace xmlsh=
$ declare namespace

Global namespace declarations are pre-declared in all <[]> , xquery, and xpath expressions.
For example

$ declare namespace test=
$ echo <[<test:foo/>]>
<test:foo xmlns:test=""/>

$ xpath -i <[ document{ <test:foo/> } ]>  /test:foo
<test:foo xmlns:test=""/>

$ xquery -i <[ document{ <test:foo/> } ]>  /test:foo
<test:foo xmlns:test=""/>

To undefine a global namespace in the current context use the syntax

declare namespace prefix=

default namespace

The default namespace can be declared by omiting the "prefix=". The default namespace passed to all xml oriented commands and is added to generated xml elements with no namespace.

$ declare namespace
$ echo <[ <foo/> ]>
<foo xmlns=""/>

The default namespace can be unset by using the empty string for the uri

$ declare namespace ''

xmlns variables

As a syntactic convenience namespaces may also be declared similarly to XML attributes by assigning a variable named "xmlns:<prefix>".
This assignement may be used as the prefix to a simple command to temporarily override namespaces for a single command invocation.

xmlns:c= some_command

Has the identical effect of
  declare namespace c= some_command

There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki