Class type Pxp_document.node


class type ['a node #extension as 'a] node = object .. end

<ID:type-node> <CALL> 'ext

node <SIG> class type 'ext node = object ... end <DESCR> This is the common class type of all classes representing nodes.

Not all classes implement all methods. As the type system of O'Caml demands that there must be always a method definition for all methods of the type, methods will raise the exception Method_not_applicable if they are called on a class not supporting them. The exception Namespace_method_not_applicable is reserved for the special case that a namespace method is invoked on a class that does not support namespaces. <SEE> sig-class-type-node </ID>

method extension : 'a
<ID:type-node-extension> <TYPE:method> <CALL> obj # extension <SIG> AUTO <DESCR> Returns the extension object of the node object obj. <DOMAIN> Applicable to element, data, comment, processing instruction, and super root nodes. </ID>
method remove : unit -> unit
<ID:type-node-remove> <CALL> obj # remove () <SIG> AUTO <DESCR> Removes obj from the tree. After this operation, obj is no longer the child of the former father node, i.e. it does neither occur in the former father's list of children nor is the former father the parent of obj. The node obj becomes orphaned.

If obj is already a root, remove does nothing.

Note: This method does not check whether the modified XML tree is still valid. <DOMAIN> Elements, comments, processing instructions, data nodes, super root nodes. <SEE> node-delete </ID>

method delete : unit
DEPRECATED METHOD remove() does exactly the same
method remove_nodes : ?pos:int -> ?len:int -> unit -> unit
<ID:type-node-remove-nodes> <CALL> obj # remove_nodes ~pos ~len () <SIG> AUTO <DESCR> Removes the specified nodes from the list of children of obj. The method deletes the nodes from position pos to pos+len-1. The optional argument pos defaults to 0. The optional argument len defaults to the length of the children list.

Note: This method does not check whether the modified XML tree is still valid. <DOMAIN> Elements. </ID>

method parent : 'a node
<ID:type-node-parent> <CALL> obj # parent <SIG> AUTO <DESCR> Get the parent node, or raise Not_found if this node is a root node. For attribute and namespace nodes, the parent is artificially defined as the element to which these nodes apply. <DOMAIN> All node types. </ID>
method root : 'a node
<ID:type-node-root> <CALL> obj # root <SIG> AUTO <DESCR> Gets the root node of the tree. Every node is contained in a tree with a root, so this method always succeeds. Note that this method searches for the root, which costs time proportional to the length of the path to the root. <DOMAIN> All node types. </ID>
method orphaned_clone : < add_node : ?force:bool -> 'a node -> unit;
add_pinstr : Pxp_dtd.proc_instruction -> unit;
append_node : 'a node -> unit;
attribute : string -> Pxp_core_types.att_value;
attribute_names : string list;
attribute_type : string -> Pxp_core_types.att_type;
attributes : (string * Pxp_core_types.att_value) list;
attributes_as_nodes : 'a node list;
classify_data_node : 'a node ->
data_node_classification;
comment : string option; complement_attlist : unit -> unit;
create_data : Pxp_dtd.dtd -> string -> 'a node;
create_element : ?name_pool_for_attribute_values:Pxp_core_types.pool ->
?position:string * int * int ->
?valcheck:bool ->
?att_values:(string * Pxp_core_types.att_value) list ->
Pxp_dtd.dtd ->
node_type ->
(string * string) list -> 'a node;
create_other : ?position:string * int * int ->
Pxp_dtd.dtd ->
node_type -> 'a node;
data : string; delete : unit;
display : ?prefixes:string Pxp_types.StringMap.t ->
?minimization:[ `AllEmpty | `DeclaredEmpty | `None ] ->
Pxp_core_types.output_stream -> Pxp_core_types.encoding -> unit;
display_prefix : string; dtd : Pxp_dtd.dtd;
dump : Format.formatter -> unit; encoding : Pxp_core_types.rep_encoding;
extension : 'a; id_attribute_name : string; id_attribute_value : string;
idref_attribute_names : string list;
insert_nodes : ?pos:int -> 'a node list -> unit;
internal_adopt : 'a node option -> int -> unit;
internal_delete : 'a node -> unit;
internal_init : string * int * int ->
Pxp_core_types.pool option ->
bool ->
Pxp_dtd.dtd ->
string ->
(string * string) list ->
(string * Pxp_core_types.att_value) list -> unit;
internal_init_other : string * int * int ->
Pxp_dtd.dtd -> node_type -> unit;
internal_set_pos : int -> unit;
iter_nodes : ('a node -> unit) -> unit;
iter_nodes_sibl : ('a node option ->
'a node ->
'a node option -> unit) ->
unit;
local_validate : ?use_dfa:bool -> ?check_data_nodes:bool -> unit -> unit;
localname : string; namespace_manager : Pxp_dtd.namespace_manager;
namespace_scope : Pxp_dtd.namespace_scope; namespace_uri : string;
namespaces_as_nodes : 'a node list;
next_node : 'a node; node_path : int list;
node_position : int; node_type : node_type;
normprefix : string; nth_node : int -> 'a node;
optional_list_attribute : string -> string list;
optional_string_attribute : string -> string option; orphaned_clone : 'b;
orphaned_flat_clone : 'b; parent : 'a node;
pinstr : string -> Pxp_dtd.proc_instruction list;
pinstr_names : string list; position : string * int * int;
previous_node : 'a node;
quick_set_attributes : (string * Pxp_core_types.att_value) list -> unit;
remove : unit -> unit; remove_nodes : ?pos:int -> ?len:int -> unit -> unit;
required_list_attribute : string -> string list;
required_string_attribute : string -> string;
reset_attribute : string -> unit; root : 'a node;
set_attribute : ?force:bool -> string -> Pxp_core_types.att_value -> unit;
set_attributes : (string * Pxp_core_types.att_value) list -> unit;
set_comment : string option -> unit; set_data : string -> unit;
set_namespace_scope : Pxp_dtd.namespace_scope -> unit;
set_nodes : 'a node list -> unit;
sub_nodes : 'a node list; validate : unit -> unit;
validate_attlist : unit -> unit;
validate_contents : ?use_dfa:bool -> ?check_data_nodes:bool -> unit -> unit;
write : ?prefixes:string list ->
?default:string ->
?minimization:[ `AllEmpty | `DeclaredEmpty | `None ] ->
Pxp_core_types.output_stream -> Pxp_core_types.encoding -> unit;
.. >
as 'b
<ID:type-node-orphaned-clone> <CALL> obj # orphaned_clone <SIG> AUTO <DESCR> Returns a clone of the node and the complete tree below this node (deep clone). The clone does not have a parent (i.e. the reference to the parent node is not cloned). While copying the subtree strings are skipped; normally the original tree and the copy tree share strings. Extension objects are cloned by invoking the clone method on the original objects; how much of the extension objects is cloned depends on the implemention of this method. <DOMAIN> All node types. <SEE> node-clone </ID>
method orphaned_flat_clone : 'b
<ID:type-node-orphaned-flat-clone> <CALL> obj # orphaned_flat_clone <SIG> AUTO <DESCR> return a clone of this element where all subnodes are omitted. The type of the node, and the attributes are the same as in the original node. The clone has no parent. <DOMAIN> All node types. </ID>
method append_node : 'a node -> unit
<ID:type-node-append-node> <CALL> obj # append_node n <SIG> AUTO <DESCR> Adds the node n to the list of children of obj. The method expects that n is a root, and it requires that n and obj share the same DTD.

Note: This method does not check whether the modified XML tree is still valid. <DOMAIN> This method is only applicable to element nodes. <SEE> node-add </ID>

method classify_data_node : 'a node -> data_node_classification
<ID:type-node-classify-data-node> <CALL> obj # classify_data_node n <SIG> AUTO <DESCR> Classifies the passed data node n, and returns whether it is reasonable to append the data node to the list of subnodes (using append_node). The following return values are possible:
method add_node : ?force:bool -> 'a node -> unit
add_node is now DEPRECATED; use append_node instead!

Append new sub nodes -- mainly used by the parser itself, but of course open for everybody. If an element is added, it must be an orphan (i.e. does not have a parent node); and after addition *this* node is the new parent. The method performs some basic validation checks if the current node has a regular expression as content model, or is EMPTY. You can turn these checks off by passing ~force:true to the method.

method insert_nodes : ?pos:int -> 'a node list -> unit
<ID:type-node-insert-nodes> <CALL> obj # insert_nodes ~pos nl <SIG> AUTO <DESCR> Inserts the list of nodes nl in-place into the list of children of obj. The insertion is performed at position pos, i.e. in the modified list of children, the first element of nl will have position pos. If the optional argument pos is not passed to the method, the list nl is appended to the list of children.

The method requires that all elements of the list nl are roots, and that all elements and obj share the same DTD.

Note: This method does not check whether the modified XML tree is still valid. <DOMAIN> Elements. </ID>

method set_nodes : 'a node list -> unit
<ID:type-node-set-nodes> <CALL> obj # set_nodes l <SIG> AUTO <DESCR> Sets the list of children to l. It is required that every member of l is either a root or was already a children of this node before the method call, and it is required that all members and the current object share the same DTD.

Former children which are not members of l are removed from the tree and get orphaned (see method remove).

Note: This method does not check whether the modified XML tree is still valid. <DOMAIN> Elements. </ID>

method add_pinstr : Pxp_dtd.proc_instruction -> unit
<ID:type-node-add-pinstr> <CALL> obj # add_pinstr pi <SIG> AUTO <DESCR> Adds the processing instruction pi to the set of processing instructions contained in obj. If obj is an element node, you can add any number of processing instructions. If obj is a processing instruction node, you can put at most one processing instruction into this node. <DOMAIN> Elements, and processing instruction nodes. </ID>
method pinstr : string -> Pxp_dtd.proc_instruction list
<ID:type-node-pinstr> <CALL> obj # pinstr n <SIG> AUTO <DESCR> Returns all processing instructions that are directly contained in obj and that have a target specification of n. <DOMAIN> All node types. However, this method is only reasonable for processing instruction nodes, and for elements; for all other node types the method will return the empty list. Note that the parser can be configured such that it creates processing instruction nodes or not; in the first case, only the processing instruction nodes contain processing instruction, in the latter case, only the elements embracing the instructions contain them. </ID>
method pinstr_names : string list
<ID:type-node-pinstr-names> <CALL> obj # pinstr_names <SIG> AUTO <DESCR> Returns the targets of all processing instructions that are directly contained in obj. <DOMAIN> All node types. However, this method is only reasonable for processing instruction nodes, and for elements; for all other node types the method will return the empty list. Note that the parser can be configured such that it creates processing instruction nodes or not; in the first case, only the processing instruction nodes contain processing instruction, in the latter case, only the elements embracing the instructions contain them. </ID>
method node_position : int
<ID:type-node-node-position> <CALL> obj # node_position <SIG> AUTO <DESCR> Returns the position of obj among all children of the parent node. Positions are counted from 0. There are several cases:
method node_path : int list
<ID:type-node-node-path> <CALL> obj # node_path <SIG> AUTO <DESCR> Returns the list of node positions describing the location of this node in the whole tree. The list describes the path from the root node down to this node; the first path element is the index of the child of the root, the second path element is the index of the child of the child, and so on, and the last path element is the index of this node. The method returns [[]] if this node is the root node.

Attribute and namespace nodes are not part of the regular tree, so there is a special rule for them. Attribute nodes of an element node x have the node path [x # node_path @ [-1; p]] where p is the position of the attribute node. Namespace nodes of an element node x have the node path [x # node_path @ [-2; p]] where p is the position of the namespace node. (This definition respects the document order.) <DOMAIN> All node types. </ID>

method sub_nodes : 'a node list
<ID:type-node-sub-nodes> <CALL> obj # sub_nodes <SIG> AUTO <DESCR> Returns the regular children of the node as list. Only elements, data nodes, comments, and processing instructions can occur in this list; attributes and namespace nodes are not considered as regular nodes, and super root nodes can only be root nodes and will never be children of another node. The returned list is always empty if obj is a data node, comment, processing instruction, attribute, or namespace. <DOMAIN> All node types. </ID>
method iter_nodes : ('a node -> unit) -> unit
<ID:type-node-iter-nodes> <CALL> obj # iter_nodes f <SIG> AUTO <DESCR> Iterates over the regular children of obj, and calls the function f for every child ch: f ch. The regular children are the nodes returned by sub_nodes, see there for an explanation. <DOMAIN> All node types. <SEE> document-iterators </ID>
method iter_nodes_sibl : ('a node option ->
'a node -> 'a node option -> unit) ->
unit
<ID:type-node-iter-nodes-sibl> <CALL> obj # iter_nodes_sibl f <SIG> AUTO <DESCR> Iterates over the regular children of obj, and calls the function f for every child: f pred ch succ.
method nth_node : int -> 'a node
<ID:type-node-nth-node> <CALL> obj # nth_node n <SIG> AUTO <DESCR> Returns the n-th regular child of obj, n >= 0. Raises Not_found if the index n is out of the valid range. <DOMAIN> All node types. </ID>
method previous_node : 'a node
<ID:type-node-previous-node> <CALL> obj # previous_node <SIG> AUTO <DESCR> Returns the predecessor of obj in the list of regular children of the parent, or raise Not_found if this node is the first child. This is equivalent to obj # parent # nth_node (obj # node_position - 1). <DOMAIN> All node types. </ID>
method next_node : 'a node
<ID:type-node-next-node> <CALL> obj # next_node <SIG> AUTO <DESCR> Returns the successor of obj in the list of regular children of the parent, or raise Not_found if this node is the last child. This is equivalent to obj # parent # nth_node (obj # node_position + 1). <DOMAIN> All node types. </ID>
method data : string
<ID:type-node-data> <CALL> obj # data <SIG> AUTO <DESCR> This method returns what is considered as the data of the node which depends on the node type:
method set_data : string -> unit
<ID:type-node-set-data> <CALL> obj # set_data s <SIG> AUTO <DESCR> This method sets the character string contained in data nodes.

Note: This method does not check whether the modified XML tree is still valid. <DOMAIN> Data nodes. </ID>

method node_type : node_type
<ID:type-node-node-type> <CALL> obj # node_type <SIG> AUTO <DESCR> Returns the type of obj:
method position : string * int * int
<ID:type-node-position> <CALL> obj # position <SIG> AUTO <DESCR> Returns a triple (entity,line,pos) describing the location of the element in the original XML text. This triple is only available for elements, and only if the parser has been configured to store positions (see parser option store_element_positions). If available, entity describes the entity where the element occurred, line is the line number >= 1, and pos is the byte position of the first character of the element in the line.

If unavailable, the method will return the triple ("?",0,0). <DOMAIN> All node types. Note that the method will always return ("?",0,0) for non-element nodes. </ID>

method attribute : string -> Pxp_core_types.att_value
<ID:type-node-attribute> <CALL> obj # attribute name <SIG> AUTO <DESCR> Returns the value of the attribute name.

If the parser is in validating mode, the method is able to return values for declared attributes, and it raises Not_found for any undeclared attribute. Note that it even returns a value if the attribute is actually missing but is declared as #IMPLIED or has a default value.

If the parser (more precisely, the DTD object) is in well-formedness mode, the method is able to return values for defined attributes, and it raises Not_found for any unknown attribute name.

Possible return values are:

Summarized, Value s is returned for non-implied, non-list attribute values.

Furthermore, Value s is returned for non-declared attributes if the DTD object allows this, for instance, if the DTD object specifies well-formedness mode.

Summarized, Valuelist l is returned for all list-type attribute values. -- Note that before the attribute value is returned, the value is normalized. This means that newlines are converted to spaces, and that references to character entities (i.e. &#n;) and general entities (i.e. &name;) are expanded; if necessary, the expansion is performed recursively. <DOMAIN> All node types. However, only elements and attribute nodes will return values, all other node types always raise Not_found. </ID>
method attribute_names : string list
<ID:type-node-attribute-names> <CALL> obj # attribute_names <SIG> AUTO <DESCR> Returns the list of all attribute names of this element. In validating mode, this list is simply the list of declared attributes. In well-formedness mode, this list is the list of defined attributes. <DOMAIN> All node types. However, only elements and attribute nodes will return a non-empty list, all other node types always return the empty list. </ID>
method attribute_type : string -> Pxp_core_types.att_type
<ID:type-node-attribute-type> <CALL> obj # attribute_type name <SIG> AUTO <DESCR> Returns the type of the attribute name. If the attribute is declared, the declared type is returned. If the attribute is defined but undeclared, the type A_cdata will be returned. (The module Pxp_types contains the Caml type of attribute types.) This method raises Not_found if the attribute is unknown. <DOMAIN> All node types. However, only elements and attribute nodes will return values, all other node types always raise Not_found. </ID>
method attributes : (string * Pxp_core_types.att_value) list
<ID:type-node-attributes> <CALL> obj # attributes <SIG> AUTO <DESCR> Returns the list of (name,value) pairs describing all attributes (declared attributes plus defined attributes). <DOMAIN> All node types. However, only elements and attribute nodes will return non-empty values, all other node types always return the empty list. </ID>
method required_string_attribute : string -> string
<ID:type-node-required-string-attribute> <CALL> obj # required_string_attribute name <SIG> AUTO <DESCR> Returns the value of the attribute name as string, i.e. if the value of the attribute is Value s, this method will return simply s, and if the value is Valuelist l, this method will return the elements of l separated by spaces. If the attribute value is Implied_value, the method will fail. <DOMAIN> All node types. However, only elements and attribute nodes will return values, all other node types always fail. </ID>
method required_list_attribute : string -> string list
<ID:type-node-required-list-attribute> <CALL> obj # required_list_attribute name <SIG> AUTO <DESCR> Returns the value of the attribute name as string list, i.e. if the value of the attribute is Valuelist l, this method will return simply l, and if the value is Value s, this method will return the one-element list [[s]]. If the attribute value is Implied_value, the method will fail. <DOMAIN> All node types. However, only elements and attribute nodes will return values, all other node types always fail. </ID>
method optional_string_attribute : string -> string option
<ID:type-node-optional-string-attribute> <CALL> obj # optional_string_attribute name <SIG> AUTO <DESCR> Returns the value of the attribute name as optional string, i.e. if the value of the attribute is Value s, this method will return Some s, and if the value is Valuelist l, this method will return Some s where s consists of the concatenated elements of l separated by spaces. If the attribute value is Implied_value, the method will return None. <DOMAIN> All node types. However, only elements and attribute nodes will return Some values, all other node types always return None. </ID>
method optional_list_attribute : string -> string list
<ID:type-node-optional-list-attribute> <CALL> obj # optional_list_attribute name <SIG> AUTO <DESCR> Returns the value of the attribute name as string list, i.e. if the value of the attribute is Valuelist l, this method will return simply l, and if the value is Value s, this method will return the one-element list [[s]]. If the attribute value is Implied_value, the method will return the empty list [[]]. <DOMAIN> All node types. However, only elements and attribute nodes will return non-empty values, all other node types always return the empty list. </ID>
method id_attribute_name : string
<ID:type-node-id-attribute-name> <CALL> obj # id_attribute_name <SIG> AUTO <DESCR> Returns the name of the (at most one) attribute being declared as type ID. The method raises Not_found if there is no declared ID attribute for the element type. <DOMAIN> All node types. However, only elements and attribute nodes will return names, all other node types always raise Not_found. </ID>
method id_attribute_value : string
<ID:type-node-id-attribute-value> <CALL> obj # id_attribute_value <SIG> AUTO <DESCR> Returns the string value of the (at most one) attribute being declared as type ID. The method raises Not_found if there is no declared ID attribute for the element type. <DOMAIN> All node types. However, only elements and attribute nodes will return names, all other node types always raise Not_found. </ID>
method idref_attribute_names : string list
<ID:type-node-idref-attribute-names> <CALL> obj # idref_attribute_names <SIG> AUTO <DESCR> Returns the names of the attributes being declared as type IDREF or IDREFS. <DOMAIN> All node types. However, only elements and attribute nodes will return names, all other node types always return the empty list. </ID>
method quick_set_attributes : (string * Pxp_core_types.att_value) list -> unit
DEPRECATED METHOD! set_attributes does exactly the same.
method set_attributes : (string * Pxp_core_types.att_value) list -> unit
<ID:type-node-set-attributes> <CALL> obj # set_attributes al <SIG> AUTO <DESCR> Sets the attributes of this element to al.

Note that this method does not add missing attributes that are declared in the DTD. It also never rejects undeclared attributes. The passed values are not checked.

Note: This method does not check whether the modified XML tree is still valid. <DOMAIN> Elements. </ID>

method set_attribute : ?force:bool -> string -> Pxp_core_types.att_value -> unit
<ID:type-node-set-attribute> <CALL> obj # set_attribute ~force n v <SIG> AUTO <DESCR> Sets the attribute n of this element to the value v. By default, it is required that the attribute n has already some value. If you pass ~force:true, the attribute is added to the attribute list if it is missing.

Note: This method does not check whether the modified XML tree is still valid. <DOMAIN> Elements. </ID>

method reset_attribute : string -> unit
<ID:type-node-reset-attribute> <CALL> obj # reset_attribute n <SIG> AUTO <DESCR> If the attribute n is a declared attribute, it is set to its default value, or to Implied_value if there is no default (the latter is performed even if the attribute is #REQUIRED). If the attribute is an undeclared attribute, it is removed from the attribute list.

The idea of this method is to simulate what had happened if n had not been defined in the attribute list of the XML element. In validating mode, the parser would have chosen the default value if possible, or Implied_value otherwise, and in well-formedness mode, the attribute would be simply missing in the attribute list.

Note: It is intentionally not possible to remove a declared attribute. (However, you can remove it by calling set_attributes, but this would be very inefficient.)

Note: This method does not check whether the modified XML tree is still valid. <DOMAIN> Elements. </ID>

method attributes_as_nodes : 'a node list
<ID:type-node-attributes-as-nodes> <CALL> obj # attributes_as_nodes <SIG> AUTO <DESCR> Returns all attributes (i.e. declared plus defined attributes) as a list of attribute nodes with node type T_attribute name.

This method should be used if it is required for typing reasons that the attributes have also type node. A common example are sets that may both contain elements and attributes, as they are used in the XPath language.

The attribute nodes are read-only; any call to a method modifying their contents will raise Method_not_applicable. In order to get the value of such an attribute node anode, one can invoke the method attribute:

anode # attribute name

where name is the name of the attribute represented by anode. This will return the attribute value as att_value. Of course, the other attribute observers can be applied as well. Furthermore, the method data will return the attribute value as string. However, every attribute node only contains the value of the one attribute it represents, and it does not make sense to pass names of other attributes to the observer methods.

The attribute nodes live outside of the regular XML tree, and they are not considered as children of the element node. However, the element node is the parent node of the attribute nodes (i.e. the children/parent relationship is asymmetric).

The method attributes_as_nodes computes the list of attribute nodes when it is first invoked, and it will return the same list again in subsequent invocations. <DOMAIN> This method is only applicable to elements. </ID>

method set_comment : string option -> unit
<ID:type-node-set-comment> <CALL> obj # set_comment c <SIG> AUTO <DESCR> Sets the comment string contained in comment nodes, if c = Some s. Otherwise, this method removes the comment string (c = None).

Note that the comment string must not include the delimiters <!-- and -->. Furthermore, it must not contain any character or character sequence that are forbidden in comments, such as "--". However, this method does not check this condition. <DOMAIN> Comment nodes. </ID>

method comment : string option
<ID:type-node-comment> <CALL> obj # comment <SIG> AUTO <DESCR> Returns Some text if the node is a comment node and if text is the comment string (without the delimiters <!-- and -->). Otherwise, None is passed back.

Note: The data method also returns the comment string, but it raises Not_found if the string is not available. <DOMAIN> All node types. Note that the method will always return None for non-comment nodes. </ID>

method normprefix : string
<ID:type-node-normprefix> <CALL> obj # normprefix <SIG> AUTO <DESCR> For namespace-aware implementations of the node class, this method returns the normalized prefix of the element or attribute. If the object does not have a prefix, "" will be passed back.

The normalized prefix is the part of the name before the colon. It is normalized because the parser ensures that every prefix corresponds only to one namespace. Note that the prefix can be different than in the parsed XML source because the normalization step needs to change the prefix to avoid prefix conflicts. <DOMAIN> Elements and attributes supporting namespaces. </ID>

method display_prefix : string
<ID:type-node-display-prefix> <CALL> obj # display_prefix <SIG> AUTO <DESCR> For namespace-aware implementations of the node class, this method returns the display prefix of the element or attribute. If the object does not have a prefix, "" will be passed back.

The display prefix is the prefix in the XML text. Unlike the normprefix, it is not unique in the document.

Actually, this method does not return the real display prefix that was found in the XML text but the most recently declared display prefix bound to the namespace URI of this element or attribute, i.e. this method infers the display prefix. The result can be a different prefix than the original prefix if the same namespace URI is bound several times in the current namespace scope.

This method is quite slow. <DOMAIN> Elements and attributes supporting namespaces. </ID>

method localname : string
<ID:type-node-localname> <CALL> obj # localname <SIG> AUTO <DESCR> For namespace-aware implementations of the node class, this method returns the local part of the name of the element or attribute.

The local name is the part of the name after the colon, or the whole name if there is no colon. <DOMAIN> Elements and attributes supporting namespaces. </ID>

method namespace_uri : string
<ID:type-node-namespace-uri> <CALL> obj # namespace_uri <SIG> AUTO <DESCR> For namespace-aware implementations of the node class, this method returns the namespace URI of the element, attribute or namespace. It is required that a namespace manager is available.

If the node does not have a namespace prefix, and there is no default namespace, this method returns "".

The namespace URI is the unique name of the namespace. <DOMAIN> Elements and attributes supporting namespaces; furthermore namespace nodes. </ID>

method namespace_manager : Pxp_dtd.namespace_manager
<ID:type-node-namespace-manager> <CALL> obj # namespace_manager <SIG> AUTO <DESCR> For namespace-aware implementations of the node class, this method returns the namespace manager. If the namespace manager has not been set, the exception Not_found is raised.

The namespace manager is an object that holds the mapping from namespace prefixes to namespace URIs, and vice versa. It is contained in the DTD. <DOMAIN> Elements and attributes supporting namespaces; furthermore namespace nodes. </ID>

method namespace_scope : Pxp_dtd.namespace_scope
<ID:type-node-namespace-scope> <CALL> obj # namespace_scope <SIG> AUTO <DESCR> Returns additional information about the namespace structure in the parsed XML text. In particular, the namespace scope describes the original (unprocessed) namespace prefixes in the XML text, and how they are mapped to the namespace URIs.

When printing XML text, the namespace scope may be used to give the printer hints where to introduce namespaces, and which namespace prefixes are preferred. <DOMAIN> Elements and attributes supporting namespaces

method set_namespace_scope : Pxp_dtd.namespace_scope -> unit
<ID:type-node-set-namespace-scope> <CALL> obj # set_namespace_scope scope <SIG> AUTO <DESCR> Sets the namespace scope object. It is required that this object is connected to the same namespace manager as the document tree. <DOMAIN> Elements and attributes supporting namespaces
method namespaces_as_nodes : 'a node list
<ID:type-node-namespaces-as-nodes> <CALL> obj # namespaces_as_nodes <SIG> AUTO <DESCR> Returns the namespaces found in the namespace_scope object and all parent scope objects (except declarations that are hidden by more recent declarations). The namespaces are returned as node objects with type T_namespace name where name is the normalized prefix.

This method should be used if it is required for typing reasons that the namespaces have also type node. A common example are sets that may both contain elements and namespaces, as they are used in the XPath language.

The namespace nodes are read-only; any call to a method modifying their contents will raise Method_not_applicable. See the class namespace_impl below for more information about the returned nodes.

The namespace nodes live outside of the regular XML tree, and they are not considered as children of the element node. However, the element node is the parent node of the namespace nodes (i.e. the children/parent relationship is asymmetric).

The method namespaces_as_nodes computes the list of attribute nodes when it is first invoked, and it will return the same list again in subsequent invocations. <DOMAIN> This method is only applicable to elements that support namespaces. </ID>

-- namespace_info is withdrawn

method namespace_info : 'ext namespace_info (** <ID:type-node-namespace-info> <CALL> obj # namespace_info <SIG> AUTO <DESCR> Returns additional information about the namespace prefixes in the parsed XML source. This method has been added for better XPath conformance. Note that it is still experimental and it is likely that it will be changed.

This record is only available if the parser has been configured to support namespaces, and if the parser has been configured to set this record (requires a lot of memory). Furthermore, only the implementation namespace_element_impl supports this method.

This method raises Not_found if the namespace_info field has not been set. <DOMAIN> Elements supporting namespaces. </ID> )

method dtd : Pxp_dtd.dtd
<ID:type-node-dtd> <CALL> obj # dtd <SIG> AUTO <DESCR> Returns the DTD. <DOMAIN> All node types. Note (1) that exemplars need not to have an associated DTD, in which case this method fails. (2) Even in well-formedness mode every node has a DTD object; this object specifies well-formedness mode. </ID>
method encoding : Pxp_core_types.rep_encoding
<ID:type-node-encoding> <CALL> obj # encoding <SIG> AUTO <DESCR> Get the encoding which is always the same as the encoding of the DTD. See also method dtd. (Note: This method fails, too, if no DTD is present.) <DOMAIN> All node types. Note that exemplars need not to have an associated DTD, in which case this method fails. </ID>
method create_element : ?name_pool_for_attribute_values:Pxp_core_types.pool ->
?position:string * int * int ->
?valcheck:bool ->
?att_values:(string * Pxp_core_types.att_value) list ->
Pxp_dtd.dtd ->
node_type -> (string * string) list -> 'a node
<ID:type-node-create-element> <CALL> obj # create_element ~name_pool_for_attribute_values ~position ~valcheck ~att_values dtd ntype att_list <SIG> AUTO <DESCR> Returns a flat copy of this element node with the following modifications: If valcheck = true (the default), it is checked whether the element type exists and whether the passed attributes match the declared attribute list. Missing attributes are automatically added, if possible. If valcheck = false, any element type and any attributes are accepted.

If a name_pool_for_attribute_values is passed, the attribute values in att_list are put into this pool.

The optional arguments have the following defaults:


method create_data : Pxp_dtd.dtd -> string -> 'a node
<ID:type-node-create-data> <CALL> obj # create_data dtd cdata <SIG> AUTO <DESCR> Returns a flat copy of this data node with the following modifications:
method create_other : ?position:string * int * int ->
Pxp_dtd.dtd -> node_type -> 'a node
<ID:type-node-create-other> <CALL> obj # create_other ~position dtd ntype <SIG> AUTO <DESCR> Returns a flat copy of this node with the following modification: The passed node type ntype must match the node type of obj. <DOMAIN> Super root nodes, processing instruction nodes, comment nodes </ID>
method local_validate : ?use_dfa:bool -> ?check_data_nodes:bool -> unit -> unit
DEPRECATED NAME of validate_contents.
method validate_contents : ?use_dfa:bool -> ?check_data_nodes:bool -> unit -> unit
<ID:type-node-validate-contents> <CALL> obj # validate_contents ?use_dfa ?check_data_nodes () <SIG> AUTO <DESCR> Checks that the subnodes of this element match the declared content model of this element. The method returns () if the element is okay, and it raises an exception if an error is found (in most cases Validation_error).

This check is always performed by the parser, such that software that only reads parsed XML trees needs not call this method. However, if software modifies the tree itself, an invocation of this method ensures that the validation constraints about content models are fulfilled.

Note that the check is not performed recursively.

See classify_data_node for details about what is checked. --

In previous releases of PXP, this method was called local_validate. <DOMAIN> All node types. However, there are only real checks for elements; for other nodes, this method is a no-op. </ID>

method complement_attlist : unit -> unit
<ID:type-node-complement-attlist> <CALL> obj # complement_attlist () <SIG> AUTO <DESCR> Adds attributes that are declared in the DTD but are currently missing: #IMPLIED attributes are added with Implied_value, and if there is a default value for an attribute, this value is added. #REQUIRED attributes are set to Implied_value, too.

It is only necessary to call this method if the element is created with ~valcheck:false, or the attribute list has been modified, and the element must be validated. <DOMAIN> Elements. </ID>

method validate_attlist : unit -> unit
<ID:type-node-validate-attlist> <CALL> obj # validate_attlist () <SIG> AUTO <DESCR> Checks whether the attribute list of the element obj matches the declared attribute list. The method returns () if the attribute list is formed correctly, and it raises an exception (usually a Validation_error) if there is an error.

This check is implicitly performed by create_element unless the option ~valcheck:false has been passed. This means that it is usually not necessary to call this method; however, if the attribute list has been changed by set_attributes or if ~valcheck:false is in effect, the invocation of this method ensures the validity of the attribute list.

Note that the method complains about missing attributes even if these attributes have been declared with a default value or as being #IMPLIED; this method only checks the attributes but does not modify the attribute list. If you know that attributes are missing and you want to add them automatically just as create_element does, you can call complement_attlist before doing this check. <DOMAIN> All node types. However, for non-element nodes this check is a no-op. </ID>

method validate : unit -> unit
<ID:type-node-validate> <CALL> obj # validate () <SIG> AUTO <DESCR> Calls validate_contents and validate_attlist, and ensures that this element is locally valid. The method returns () if the element is valid, and raises an exception otherwise. <DOMAIN> All node types. However, for non-element nodes this check is a no-op. </ID>

method keep_always_whitespace_mode : unit

This method has been removed. You can now set the handling of ignorable whitespace by a new Pxp_yacc.config option:

drop_ignorable_whitespace
method write : ?prefixes:string list ->
?default:string ->
?minimization:[ `AllEmpty | `DeclaredEmpty | `None ] ->
Pxp_core_types.output_stream -> Pxp_core_types.encoding -> unit
<ID:type-node-write> <CALL> obj # write ~prefixes stream enc <SIG> AUTO <DESCR> Write the contents of this node and the subtrees to the passed stream encoded as enc. The generated output is again XML. The output style is rather compact and should not be considered as "pretty printing".

The namespace-aware nodes use a notation with normalized prefixes. The namespace scope is ignored.

Option ~prefixes: The class namespace_element_impl interprets this option and passes it recursively to subordinate invocations of write. The meaning is that the normprefixes enumerated by this list have already been declared by surrounding elements. The option defaults to [] forcing the method to output all necessary prefix declarations.

Option ~default: Specifies the normprefix that becomes the default namespace in the output.

Option ~minimization: How to write out empty elements. `AllEmpty means that all empty elements are minimized (using the <name/> form). `DeclaredEmpty minimizes only empty elements that are declared as empty in the DTD. `None does not minimize at all and is the default. <DOMAIN> All regular node types (elements, data nodes, comments, processing instructions, super root nodes). </ID>

method display : ?prefixes:string Pxp_types.StringMap.t ->
?minimization:[ `AllEmpty | `DeclaredEmpty | `None ] ->
Pxp_core_types.output_stream -> Pxp_core_types.encoding -> unit
<ID:type-node-display> <CALL> obj # display ~prefixes stream enc <SIG> AUTO <DESCR> Write the contents of this node and the subtrees to the passed stream encoded as enc. The generated output is again XML. The output style is rather compact and should not be considered as "pretty printing".

The namespace-aware nodes try to follow the namespace scoping found in the nodes. The generated namespace prefixes are display prefixes. Missing prefixes are complemented, but this is slow.

Option ~prefixes: The class namespace_element_impl interprets this option and passes it recursively to subordinate invocations of display. The mapping contains the declarations currently in effect as pairs of (prefix,uri). The option defaults to [] forcing the method to output all necessary prefix declarations.

Option ~minimization: How to write out empty elements. `AllEmpty means that all empty elements are minimized (using the <name/> form). `DeclaredEmpty minimizes only empty elements that are declared as empty in the DTD. `None does not minimize at all and is the default. <DOMAIN> All regular node types (elements, data nodes, comments, processing instructions, super root nodes). </ID>

----------------------------------------

method internal_adopt : 'a node option -> int -> unit
internal methods:
method internal_set_pos : int -> unit
method internal_delete : 'a node -> unit
method internal_init : string * int * int ->
Pxp_core_types.pool option ->
bool ->
Pxp_dtd.dtd ->
string ->
(string * string) list -> (string * Pxp_core_types.att_value) list -> unit
method internal_init_other : string * int * int -> Pxp_dtd.dtd -> node_type -> unit
method dump : Format.formatter -> unit