Revision [299]
This is an old revision of Namespaces made by DavidLee on 2008-11-21 09:45:16.
Namespaces
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
Example
$ declare namespace xmlsh=http://www.xmlsh.org/namespaces/xmlsh $ declare namespace xmlsh=http://www.xmlsh.org/namespaces/xmlsh
Global namespace declarations are pre-declared in all <[]> , xquery, and xpath expressions.
For example
$ declare namespace test=http://www.example.org/test $ echo <[<test:foo/>]> <test:foo xmlns:test="http://www.example.org/test"/>
$ xpath -i <[ document{ <test:foo/> } ]> /test:foo <test:foo xmlns:test="http://www.example.org/test"/>
$ xquery -i <[ document{ <test:foo/> } ]> /test:foo <test:foo xmlns:test="http://www.example.org/test"/>
To undefine a global namespace in the current context use the syntax
$ declare namespace prefix=
CommandsBuiltin
The declare command is used to add global declarations to the shell. Currently the declare namespaces is the only declaration.
Future may include serialization
Example
$ declare namespace xmlsh=http://www.xmlsh.org/namespaces/xmlsh $ declare namespace xmlsh=http://www.xmlsh.org/namespaces/xmlsh
CommandsBuiltin
q