Revision [294]

This is an old revision of Namespaces made by DavidLee on 2008-11-21 09:43:32.

 

Namespaces


declare namespace [prefix=uri]

declare namespace

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"/>








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
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki