## Class node

zeep::xml::node

## Synopsis

    // 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 *);
    };

## Description

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 construct/copy/destruct

1.     node() = default;

2.     node(const node & n) = delete;

3.     node(node && n) = delete;

4.     node & operator=(const node & n) = delete;

5.     node & operator=(node && n) = delete;

6.     ~node();

### `node` public member functions

1.     virtual std::string lang() const;

   content of a xml:lang attribute of this element, or its nearest ancestor

2.     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.

3.     virtual void set_qname(const std::string &);

4.     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:

   `name` | The actual name to use
   `prefix` | The namespace prefix to use

5.     virtual std::string name() const;

   The name for the node as parsed from the qname.

6.     virtual std::string get_prefix() const;

   The prefix for the node as parsed from the qname.

7.     virtual std::string get_ns() const;

   Returns the namespace URI for the node, if it can be resolved.

8.     virtual std::string namespace_for_prefix(const std::string & prefix) const;

   Return the namespace URI for a prefix.

9.     virtual std::pair< std::string, bool >
       prefix_for_namespace(const std::string & uri) const;

   Return the prefix for a namespace URI.

10.     virtual std::string
        prefix_tag(const std::string & tag, const std::string & uri) const;

    Prefix the tag with the namespace prefix for uri.

11.     virtual std::string str() const = 0;

    return all content concatenated, including that of children.

12.     virtual void set_text(const std::string & value) = 0;

    Set text, what really happens depends on the type of the subclass implementing this method.

13.     virtual element * root();

    The root node for this node.

14.     virtual const element * root() const;

    The root node for this node.

15.     element * parent();

    The parent node for this node.

16.     const element * parent() const;

    The parent node for this node.

17.     node * next();

    The next sibling.

18.     const node * next() const;

    The next sibling.

19.     node * prev();

    The previous sibling.

20.     const node * prev() const;

    The previous sibling.

21.     virtual bool equals(const node * n) const;

    Compare the node with n.

22.     virtual void validate();

    debug routine

23.     virtual node * clone() const = 0;

    return an exact copy of this node, including all data in sub nodes

24.     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.

25.     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&)

### `node` protected member functions

1.     virtual void insert_sibling(node * n, node * before);

2.     virtual void remove_sibling(node * n);

3.     void parent(element * p);

4.     void next(node * n);

5.     void prev(node * n);