class namespace_manager :object
..end
np
:
uri1 |-> np, uri2 |-> np, ..., uriN |-> np
The normalized prefix np
is characterstical of the namespace, and
identifies the namespace uniquely.
The first URI uri1
is the primary URI, the other URIs are aliases.
In order to create an empty namespace, call
Pxp_dtd.create_namespace_manager
.
See Intro_namespaces
for an introduction to namespaces and more
links to other explanations about namespace managers.
The following operations are supported:
add_namespace np uri
: adds a new mapping uri |-> np
to the
manager. Neither np
nor uri
must already be part of another
mapping in the manager.add_uri np uri
: adds a new alias uri
for an existing namespace
which is identified by the normprefix np
. The normprefix np
must already be part of a mapping which is then extended by this
method.lookup_or_add_namespace p uri
: If there is already some mapping
uri |-> np
, the normprefix np
is simply returned ("lookup"). In this
case p
is ignored. Otherwise uri
is not yet mapped, and in this
case some unique np
must be found such that uri |-> np
can be
added (add_namespace
). First, the passed prefix p
is tried.
If p
is free, it can be taken as new normprefix: np = p
. Otherwise
some number n
is found such that the concatenation p ^ n
is free:
np = p ^ n
. The operation returns np
.method add_namespace : string -> string -> unit
add_namespace np uri
: adds a new namespace to the object. The
namespace is identified by the normprefix np
and contains initially
the primary URI uri
.
The method fails (Namespace_error
) if either np
already identifies
some namespace or if uri
is already member of some namespace.
Nothing happens if uri
is the sole member of the namespace np
.
It is required that np <> ""
.method add_uri : string -> string -> unit
add_uri np uri
: adds uri
as alias URI to the namespace identified
by the normprefix np
(see above for detailed semantics). The method
raises Namespace_prefix_not_managed
if the normprefix np
is unknown
to the object,
and it fails (Namespace_error
) if the uri
is member of a
different namespace. Nothing happens if the uri
is already member
of the namespace np
.
Change in PXP 1.2: Using exception Namespace_prefix_not_managed
instead of Not_found
.
method lookup_or_add_namespace : string -> string -> string
lookup_or_add_namespace p uri
: first, the method looks up if
the namespace for uri
does already exist. If so, p
is ignored,
and the method returns the normprefix identifying the namespace.
Otherwise, a new namespace is added for some normprefix np
which
initially contains uri
. The normprefix np
is calculated upon p
serving as suggestion for the normprefix. The method returns
the normprefix.method get_primary_uri : string -> string
Namespace_prefix_not_managed
. get_uri ""
raises always this
exception.method get_uri_list : string -> string list
[]
if the normprefix is
unused. get_uri_list ""
returns always []
. The last URI of the
returned list is the primary URI.method get_normprefix : string -> string
Namespace_not_managed
.method iter_namespaces : (string -> unit) -> unit
method as_declaration : (string * string) list
new namespace_scope_impl mng None (mng#as_declaration)