Plasma GitLab Archive
Projects Blog Knowledge

Class type Pxp_dtd.namespace_scope

class type namespace_scope = object .. end
The recursive class type namespace_scope represents the original namespace declarations found in the XML text. A single namespace_scope object contains a list of declared namespaces
 [ (dp1, uri1); (dp2; uri2); ... ] 
corresponding to the "xmlns"-type declarations found in a single XML element:
 <element xmlns:dp1="uri1" xmlns:dp2="uri2" ... > 
For the declaration of a default namespace xmlns="uri" the pair ("",uri) must be included in the list. The special pair ("","") means that the former default namespace is "undeclared".

Furthermore, the namespace_scope object may have a parent namespace_scope, representing the namespace declarations in the surrounding XML text. namespace_scope objects are intentionally immutable. When some XML subtree is cut out of a document and inserted into another document, the original namespace_scope declarations (including all parents) are still applied to the subtree when it is in the new document. Further changes in the old document cannot break this assertion because of the immutability.

The namespace_scope objects are connected with the namespace_manager to allow translations from the namespace prefixes found in the XML text (also called "display prefixes" from now on) to the normalized prefixes stored in the namespace_manager, and vice versa.

Call Pxp_dtd.create_namespace_scope to create a scope object using the default implementation.

See Intro_namespaces for an introduction to namespaces and more links to other explanations about scopes.


method namespace_manager : namespace_manager
Returns the namespace_manager to which this scope object is connected
method parent_scope : namespace_scope option
Returns the parent object, if any
method declaration : (string * string) list
Returns the list of namespace declarations of this scope (i.e. the declarations in parent objects are not considered). The list contains pairs (display_prefix, uri) .
method effective_declaration : (string * string) list
Returns the list of namespace declarations of this scope and all parent scopes. The list contains pairs (display_prefix, uri) . Prefixes hidden by earlier declarations are suppressed in the list
method display_prefix_of_uri : string -> string
Translates the URI to the corresponding display prefix as declared in this object or any parent object. Raises Namespace_not_in_scope when the declaration cannot be found.
method display_prefix_of_normprefix : string -> string
Translates the normalized prefix to the corresponding display prefix as declared in this object or any parent object. Raises Namespace_not_in_scope when the declaration cannot be found, and Namespace_prefix_not_managed when the normalized prefix is unknown to the namespace manager.
method uri_of_display_prefix : string -> string
Translates the display prefix to the corresponding URI as declared in this object or any parent object. Raises Not_found when the declaration cannot be found.
method normprefix_of_display_prefix : string -> string
Translates the display prefix to the corresponding normalized prefix as declared in this object or any parent object. Raises Not_found when the declaration cannot be found, and Namespace_not_managed when the namespace manager does not know the namespace.
This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml