![]() |
zeep::xml::node
// In header: <zeep/xml/node.hpp> class node { public: // types typedef element parent_type; // construct/copy/destruct node() = default; node(const node &) = delete; node(node &&) = delete; node & operator=(const node &) = delete; node & operator=(node &&) = delete; ~node(); // public member functions virtual std::string lang() const; virtual std::string get_qname() const; virtual void set_qname(const std::string &); virtual void set_qname(const std::string &, const std::string &); virtual std::string name() const; virtual std::string get_prefix() const; virtual std::string get_ns() const; virtual std::string namespace_for_prefix(const std::string &) const; virtual std::pair< std::string, bool > prefix_for_namespace(const std::string &) const; virtual std::string prefix_tag(const std::string &, const std::string &) const; virtual std::string str() const = 0; virtual void set_text(const std::string &) = 0; virtual element * root(); virtual const element * root() const; element * parent(); const element * parent() const; node * next(); const node * next() const; node * prev(); const node * prev() const; virtual bool equals(const node *) const; virtual void validate(); virtual node * clone() const = 0; virtual node * move() = 0; virtual void write(std::ostream &, format_info) const = 0; // protected member functions virtual void insert_sibling(node *, node *); virtual void remove_sibling(node *); void parent(element *); void next(node *); void prev(node *); };
Node is the abstract base class for all data contained in zeep XML documents. The DOM tree consists of nodes that are linked to each other, each node can have a parent and siblings pointed to by the next and previous members. All nodes in a DOM tree share a common root node.
Nodes can have a name, and the XPath specification requires that a node can have a so-called expanded-name. This name consists of a local-name and a namespace which is a URI. And we can have a QName which is a concatenation of a prefix (that points to a namespace URI) and a local-name separated by a colon.
To reduce storage requirements, names are stored in nodes as qnames, if at all. the convenience functions name() and prefix() parse the qname(). ns() returns the namespace URI for the node, if it can be resolved.
Nodes inherit the namespace of their parent unless they override it which means resolving prefixes and namespaces is done hierarchically
Nodes are stored in a node_list, a generic list class that resembles std::list
node
public member functionsvirtual std::string lang() const;content of a xml:lang attribute of this element, or its nearest ancestor
virtual std::string get_qname() const;
Nodes can have a name, and the XPath specification requires that a node can have a so-called expanded-name. This name consists of a local-name and a namespace which is a URI. And we can have a QName which is a concatenation of a prefix (that points to a namespace URI) and a local-name separated by a colon.
To reduce storage requirements, names are stored in nodes as qnames, if at all.
virtual void set_qname(const std::string & qn);
virtual void set_qname(const std::string & prefix, const std::string & name);set the qname with two parameters, if prefix is empty the qname will be simply name otherwise the name will be
prefix:name
Parameters: |
|
virtual std::string name() const;The name for the node as parsed from the qname.
virtual std::string get_prefix() const;The prefix for the node as parsed from the qname.
virtual std::string get_ns() const;Returns the namespace URI for the node, if it can be resolved.
virtual std::string namespace_for_prefix(const std::string & prefix) const;Return the namespace URI for a prefix.
virtual std::pair< std::string, bool > prefix_for_namespace(const std::string & uri) const;Return the prefix for a namespace URI.
virtual std::string prefix_tag(const std::string & tag, const std::string & uri) const;Prefix the tag with the namespace prefix for uri.
virtual std::string str() const = 0;return all content concatenated, including that of children.
virtual void set_text(const std::string & value) = 0;Set text, what really happens depends on the type of the subclass implementing this method.
virtual element * root();The root node for this node.
virtual const element * root() const;The root node for this node.
element * parent();The parent node for this node.
const element * parent() const;The parent node for this node.
node * next();The next sibling.
const node * next() const;The next sibling.
node * prev();The previous sibling.
const node * prev() const;The previous sibling.
virtual bool equals(const node * n) const;Compare the node with n.
virtual void validate();debug routine
virtual node * clone() const = 0;return an exact copy of this node, including all data in sub nodes
virtual node * move() = 0;
return a copy of this node, including all data in sub nodes, but in contrast with clone the data is moved from this node to the cloned node. This node will be empty afterwards.
virtual void write(std::ostream & os, format_info fmt) const = 0;low level routine for writing out XML
This method is usually called by operator<<(std::ostream&, zeep::xml::document&)