## Class document

zeep::xml::document

## Synopsis

    // In header: <zeep/xml/document.hpp>

    class document : public zeep::xml::element {
    public:
      // member classes/structs/unions

      struct notation {

        // public data members
        std::string m_name;
        std::string m_sysid;
        std::string m_pubid;
      };
      // construct/copy/destruct
      document();
      document(const document &);
      document(document &&);
      document(const std::string &);
      document(std::istream &);
      document(std::istream &, const std::string &);
      document & operator=(const document &);
      document & operator=(document &&);
      ~document();

      // public member functions
      bool is_validating() const;
      void set_validating(bool);
      bool is_validating_ns() const;
      void set_validating_ns(bool);
      bool preserves_cdata() const;
      void set_preserve_cdata(bool);
      bool collapses_empty_tags() const;
      void set_collapse_empty_tags(bool);
      bool write_html() const;
      void set_write_html(bool);
      bool suppresses_comments() const;
      void set_suppress_comments(bool);
      bool escapes_white_space() const;
      void set_escape_white_space(bool);
      bool escapes_double_quote() const;
      void set_escape_double_quote(bool);
      bool wraps_prolog() const;
      void set_wrap_prolog(bool);
      doc_type get_doctype() const;
      void set_doctype(const std::string &, const std::string &,
                       const std::string &);
      void set_doctype(const doc_type &);
      bool writes_xml_decl() const;
      void set_write_xml_decl(bool);
      bool writes_doctype() const;
      void set_write_doctype(bool);
      bool is_html5() const;
      template<typename T> void serialize(const char *, const T &);
      template<typename T> void deserialize(const char *, T &);
      bool operator==(const document &) const;
      bool operator!=(const document &) const;
      void set_base_dir(const std::string &);
      template<typename Callback> void set_entity_loader(Callback &&);
      encoding_type get_encoding() const;
      void set_encoding(encoding_type);
      float get_version() const;
      void set_version(float);
      virtual element * root();
      virtual const element * root() const;
      virtual node * child();
      virtual const node * child() const;

      // friend functions
      std::ostream & operator<<(std::ostream &, const document &);
      std::istream & operator>>(std::istream &, document &);

      // protected member functions
      virtual node_iterator insert_impl(const_iterator, node *);
      void XmlDeclHandler(encoding_type, bool, float);
      void StartElementHandler(const std::string &, const std::string &,
                               const parser::attr_list_type &);
      void EndElementHandler(const std::string &, const std::string &);
      void CharacterDataHandler(const std::string &);
      void ProcessingInstructionHandler(const std::string &, const std::string &);
      void CommentHandler(const std::string &);
      void StartCdataSectionHandler();
      void EndCdataSectionHandler();
      void StartNamespaceDeclHandler(const std::string &, const std::string &);
      void EndNamespaceDeclHandler(const std::string &);
      void DoctypeDeclHandler(const std::string &, const std::string &,
                              const std::string &);
      void NotationDeclHandler(const std::string &, const std::string &,
                               const std::string &);
      std::istream *
      external_entity_ref(const std::string &, const std::string &,
                          const std::string &);
      void parse(std::istream &);
      virtual void write(std::ostream &, format_info) const;
    };

## Description

### `document` public construct/copy/destruct

1.     document();

   Constructor for an empty document.

2.     document(const document & doc);

   Copy constructor.

3.     document(document && other);

   Move constructor.

4.     document(const std::string & s);

   Constructor that will parse the XML passed in argument using default settings s.

5.     document(std::istream & is);

   Constructor that will parse the XML passed in argument using default settings is.

6.     document(std::istream & is, const std::string & base_dir);

   Constructor that will parse the XML passed in argument is. This constructor will also validate the input using DTD's found in base_dir.

7.     document & operator=(const document & doc);

   Copy operator=.

8.     document & operator=(document && other);

   Move operator=.

9.     ~document();

### `document` public member functions

1.     bool is_validating() const;

   options for parsing validating uses a DTD if it is defined

2.     void set_validating(bool validate);

3.     bool is_validating_ns() const;

   validating_ns: when validating take the NS 1.0 specification into account

4.     void set_validating_ns(bool validate);

5.     bool preserves_cdata() const;

   preserve cdata, preserves CDATA sections instead of converting them into text nodes.

6.     void set_preserve_cdata(bool p);

   if p is true, the CDATA sections will be preserved when parsing XML, if p is false, the content of the CDATA will be treated as text

7.     bool collapses_empty_tags() const;

   collapse means replacing e.g. `<foo></foo>` with `<foo/>`

8.     void set_collapse_empty_tags(bool c);

   if c is true, empty tags will be replaced, i.e. write `<foo/>` instead of `<foo></foo>`

9.     bool write_html() const;

   collapse 'empty elements' according to HTML rules

10.     void set_write_html(bool f);

    if c is true, 'empty elements' will be collapsed according to HTML rules

11.     bool suppresses_comments() const;

    whether to write out comments

12.     void set_suppress_comments(bool s);

    if s is true, comments will not be written

13.     bool escapes_white_space() const;

    whether to escape white space

14.     void set_escape_white_space(bool e);

    if e is true, white space will be written as XML entities

15.     bool escapes_double_quote() const;

    whether to escape double quotes

16.     void set_escape_double_quote(bool e);

    if e is true, double quotes will be written as "

17.     bool wraps_prolog() const;

    whether to place a newline after a prolog

18.     void set_wrap_prolog(bool w);

    if w is true, a newline will be written after the XML prolog

19.     doc_type get_doctype() const;

    Get the doctype as parsed.

20.     void set_doctype(const std::string & root, const std::string & pubid,
                         const std::string & dtd);

    Set the doctype to write out.

21.     void set_doctype(const doc_type & doctype);

    Set the doctype to write out.

22.     bool writes_xml_decl() const;

    whether to write a XML prolog

23.     void set_write_xml_decl(bool w);

    if w is true, an XML prolog will be written

24.     bool writes_doctype() const;

    whether to write a DOCTYPE

25.     void set_write_doctype(bool f);

    if f is true a DOCTYPE will be written

26.     bool is_html5() const;

    Check the doctype to see if this is supposed to be HTML5.

27.     template<typename T> void serialize(const char * name, const T & data);

    Serialization support.

    Serialize data into a document containing name as root node

28.     template<typename T> void deserialize(const char * name, T & data);

    Serialization support.

    Deserialize root node with name name into data.

29.     bool operator==(const document & doc) const;

    Compare two xml documents.

30.     bool operator!=(const document & doc) const;

31.     void set_base_dir(const std::string & path);

    If you want to validate the document using DTD files stored on disk, you can specifiy this directory prior to reading the document.

32.     template<typename Callback> void set_entity_loader(Callback && cb);

    If you want to be able to load external documents other than trying to read them from disk you can set a callback here.

33.     encoding_type get_encoding() const;

    The text encoding as detected in the input.

34.     void set_encoding(encoding_type enc);

    The text encoding to use for output.

35.     float get_version() const;

    XML version, should be either 1.0 or 1.1.

36.     void set_version(float v);

    XML version, should be either 1.0 or 1.1.

37.     virtual element * root();

    The root node for this node.

38.     virtual const element * root() const;

    The root node for this node.

39.     virtual node * child();

40.     virtual const node * child() const;

### `document` friend functions

1.     std::ostream & operator<<(std::ostream & os, const document & doc);

   Write out the document.

2.     std::istream & operator>>(std::istream & is, document & doc);

   Read in a document.

### `document` protected member functions

1.     virtual node_iterator insert_impl(const_iterator pos, node * n);

2.     void XmlDeclHandler(encoding_type encoding, bool standalone, float version);

3.     void StartElementHandler(const std::string & name, const std::string & uri,
                                const parser::attr_list_type & atts);

4.     void EndElementHandler(const std::string & name, const std::string & uri);

5.     void CharacterDataHandler(const std::string & data);

6.     void ProcessingInstructionHandler(const std::string & target,
                                         const std::string & data);

7.     void CommentHandler(const std::string & comment);

8.     void StartCdataSectionHandler();

9.     void EndCdataSectionHandler();

10.     void StartNamespaceDeclHandler(const std::string & prefix,
                                       const std::string & uri);

11.     void EndNamespaceDeclHandler(const std::string & prefix);

12.     void DoctypeDeclHandler(const std::string & root,
                                const std::string & publicId,
                                const std::string & uri);

13.     void NotationDeclHandler(const std::string & name, const std::string & sysid,
                                 const std::string & pubid);

14.     std::istream *
        external_entity_ref(const std::string & base, const std::string & pubid,
                            const std::string & sysid);

15.     void parse(std::istream & data);

16.     virtual void write(std::ostream & os, format_info fmt) const;

    low level routine for writing out XML

    This method is usually called by operator<<(std::ostream&, zeep::xml::document&)