# Class node

- Defined in File node.hpp

## Inheritance Relationships

### Derived Types

- `public zeem::attribute` (Class attribute)

- `public zeem::element_container` (Class element_container)

- `public zeem::node_with_text` (Class node_with_text)

## Class Documentation

class node

  The node base class.

  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

  Subclassed by zeem::attribute, zeem::element_container, zeem::node_with_text

  Public Functions

  virtual node_type type() const = 0

    node_type to be returned by each implementation of this node class

  virtual std::string lang() const

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

  virtual std::string get_qname() const

    Get the qualified name.

    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.

    Returns:

      std::string

  inline virtual void set_qname(std::string qn)

    Set the qualified name to qn.

    This is only meaningful in attributes and elements.

    Parameters:

      qn –

  inline void set_qname(const std::string &prefix, 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:

      - prefix – The namespace prefix to use

      - name – The actual name to use

  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(std::string_view prefix) const

    Return the namespace URI for a prefix.

  virtual std::pair<std::string, bool> prefix_for_namespace(std::string_view uri) const

    Return the prefix for a namespace URI.

  virtual std::string prefix_tag(const std::string &tag, std::string_view 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 element_container *root()

    The root node for this node.

  virtual const element_container *root() const

    The root node for this node.

  inline void parent(element_container *p) noexcept

    Set parent to p.

  inline element_container *parent()

    The parent node for this node.

  inline const element_container *parent() const

    The parent node for this node.

  inline void next(const node *n) noexcept

    Set next to n.

  inline node *next()

    The next sibling.

  inline const node *next() const

    The next sibling.

  inline void prev(const node *n) noexcept

    Set prev to n.

  inline node *prev()

    The previous sibling.

  inline const node *prev() const

    The previous sibling.

  virtual bool equals(const node *n) const

    Compare the node with n.

  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&, zeem::document&)