NCBI C++ ToolKit
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
xml::document Class Reference

Search Toolkit Book for xml::document

The xml::document class is used to hold the XML tree and various bits of information about it. More...

#include <misc/xmlwrapp/document.hpp>

+ Inheritance diagram for xml::document:
+ Collaboration diagram for xml::document:

Public Types

typedef std::size_t size_type
 size type More...
 

Public Member Functions

 document (void)
 Create a new XML document with the default settings. More...
 
 document (const char *filename, error_messages *messages, warnings_as_errors_type how=type_warnings_not_errors)
 Create a new XML document object by parsing the given XML file. More...
 
 document (const char *data, size_type size, error_messages *messages, warnings_as_errors_type how=type_warnings_not_errors)
 Create a new XML documant object by parsing the given XML from a memory buffer. More...
 
 document (const char *root_name)
 Create a new XML document and set the name of the root element to the given text. More...
 
 document (const node &n)
 Create a new XML document and set the root node. More...
 
 document (const document_proxy &doc_proxy)
 Creates a new XML document using the document_proxy, i.e. More...
 
 document (std::istream &stream, error_messages *messages, warnings_as_errors_type how=type_warnings_not_errors)
 Creates a new XML document by parsing the given XML from a stream. More...
 
void swap (document &other)
 Swap one xml::document object for another. More...
 
documentassign (const document &other)
 Copy another document object into this one. More...
 
virtual ~document (void)
 Clean up after an XML document object. More...
 
const nodeget_root_node (void) const
 Get a reference to the root node of this document. More...
 
nodeget_root_node (void)
 Get a reference to the root node of this document. More...
 
void set_root_node (const node &n)
 Set the root node to the given node. More...
 
const std::stringget_version (void) const
 Get the XML version for this document. More...
 
void set_version (const char *version)
 Set the XML version number for this document. More...
 
const std::stringget_encoding (void) const
 Get the XML encoding for this document. More...
 
void set_encoding (const char *encoding)
 Set the XML encoding string. More...
 
bool get_is_standalone (void) const
 Find out if the current document is a standalone document. More...
 
void set_is_standalone (bool sa)
 Set the standalone flag. More...
 
bool process_xinclude (void)
 Walk through the document and expand <xi:include> elements. More...
 
bool has_internal_subset (void) const
 Test to see if this document has an internal subset. More...
 
const dtdget_internal_subset (void) const
 Provides the DTD data that is declared within the XML document itself. More...
 
bool has_external_subset (void) const
 Test to see if this document has an external subset. More...
 
const dtdget_external_subset (void) const
 Provides the DTD data that is referenced from an external source, such as a file or URL. More...
 
void set_external_subset (const dtd &dtd_)
 Sets the document external subset. More...
 
bool validate (error_messages *messages_=NULL, warnings_as_errors_type how=type_warnings_are_errors) const
 Validate this document against the DTD that has been attached to it. More...
 
bool validate (const dtd &dtd_, error_messages *messages_, warnings_as_errors_type how=type_warnings_are_errors) const
 Validate this document against the given DTD. More...
 
bool validate (const schema &schema_, error_messages *messages_, warnings_as_errors_type how=type_warnings_are_errors) const
 Validate this document against the given XSD schema. More...
 
size_type size (void) const
 Returns the number of child nodes of this document. More...
 
node::iterator begin (void)
 Get an iterator to the first child node of this document. More...
 
node::const_iterator begin (void) const
 Get a const_iterator to the first child node of this document. More...
 
node::iterator end (void)
 Get an iterator that points one past the last child node for this document. More...
 
node::const_iterator end (void) const
 Get a const_iterator that points one past the last child node for this document. More...
 
void push_back (const node &child)
 Add a child xml::node to this document. More...
 
node::iterator insert (const node &n)
 Insert a new child node. More...
 
node::iterator insert (node::iterator position, const node &n)
 Insert a new child node. More...
 
node::iterator replace (node::iterator old_node, const node &new_node)
 Replace the node pointed to by the given iterator with another node. More...
 
node::iterator erase (node::iterator to_erase)
 Erase the node that is pointed to by the given iterator. More...
 
node::iterator erase (node::iterator first, node::iterator last)
 Erase all nodes in the given range, from frist to last. More...
 
void save_to_string (std::string &s, save_option_flags flags=save_op_default) const
 Convert the XML document tree into XML text data and place it into the given string. More...
 
void save_to_string_canonical (std::string &str, canonicalization_option c14n_option, canonicalization_comments_option comments_option, canonicalization_format_option format_option, canonicalization_node_sort_option node_sort_option) const
 Convert the XML document tree into XML text data and place it into the given string. More...
 
bool save_to_file (const char *filename, save_option_flags flags=save_op_default) const
 Convert the XML document tree into XML text data and place it into the given filename. More...
 
void save_to_stream (std::ostream &stream, save_option_flags flags=save_op_default) const
 Convert the XML document tree into XML text data and then insert it into the given stream. More...
 
 document (const document &other)
 Copy construct a new XML document. More...
 
documentoperator= (const document &other)
 Copy another document object into this one using the assignment operator. More...
 
 document (document &&other)
 Moving constructor. More...
 
documentoperator= (document &&other)
 Moving assignment. More...
 

Private Member Functions

void set_doc_data (void *data)
 
void set_doc_data_from_xslt (void *data, void *ssheet)
 
void * get_doc_data (void)
 
void * get_doc_data_read_only (void) const
 
void * release_doc_data (void)
 
bool is_failure (error_messages *messages, warnings_as_errors_type how) const
 
friend void ::xslt_ext_func_cb (void *, int)
 
friend void ::xslt_ext_element_cb (void *, void *, void *, void *)
 

Private Attributes

impl::doc_implpimpl_
 

Friends

class xslt::stylesheet
 
class schema
 
class dtd
 
class libxml2_document
 
class node
 
std::ostream & operator<< (std::ostream &stream, const document &doc)
 Convert the XML document tree into XML text data and then insert it into the given stream. More...
 

Detailed Description

The xml::document class is used to hold the XML tree and various bits of information about it.

Definition at line 80 of file document.hpp.

Member Typedef Documentation

◆ size_type

typedef std::size_t xml::document::size_type

size type

Definition at line 83 of file document.hpp.

Constructor & Destructor Documentation

◆ document() [1/9]

xml::document::document ( void  )

Create a new XML document with the default settings.

The new document will contain a root node with a name of "blank".

Author
Peter Jones

Definition at line 225 of file document.cpp.

◆ document() [2/9]

xml::document::document ( const char *  filename,
error_messages messages,
warnings_as_errors_type  how = type_warnings_not_errors 
)

Create a new XML document object by parsing the given XML file.

Parameters
filenameThe XML file name.
messagesA pointer to the object where all the warnings are collected. If NULL then no messages will be collected.
howHow to treat warnings (default: warnings are not treated as errors). If warnings are treated as errors then an exception is thrown in case of both errors and/or warnings. If warnings are not treated as errors then an exception will be thrown only when there are errors.
Exceptions
Throwsxml::parser_exception in case of parsing errors and std::exception in case of other problems.
Author
Sergey Satskiy, NCBI

Definition at line 286 of file document.cpp.

References xml::impl::clear_https_messages(), xml::impl::collect_https_messages(), xml::error_messages::get_messages(), is_failure(), NULL, pimpl_, set_doc_data(), test, xml::error_message::type_fatal_error, and xmlSAXParseFileWithData_Custom().

◆ document() [3/9]

xml::document::document ( const char *  data,
size_type  size,
error_messages messages,
warnings_as_errors_type  how = type_warnings_not_errors 
)

Create a new XML documant object by parsing the given XML from a memory buffer.

Parameters
dataThe XML memory buffer.
sizeSize of the memory buffer.
messagesA pointer to the object where all the warnings are collected. If NULL then no messages will be collected.
howHow to treat warnings (default: warnings are not treated as errors). If warnings are treated as errors then an exception is thrown in case of both errors and/or warnings. If warnings are not treated as errors then an exception will be thrown only when there are errors.
Exceptions
Throwsxml::parser_exception in case of parsing errors and std::exception in case of other problems.
Author
Sergey Satskiy, NCBI

Definition at line 341 of file document.cpp.

References xml::impl::clear_https_messages(), xml::impl::collect_https_messages(), data, xml::error_messages::get_messages(), is_failure(), pimpl_, set_doc_data(), set_parser_context_options(), size(), and xml::size_t_to_int_conversion().

◆ document() [4/9]

xml::document::document ( const char *  root_name)
explicit

Create a new XML document and set the name of the root element to the given text.

Parameters
root_nameWhat to set the name of the root element to.
Author
Peter Jones

Definition at line 402 of file document.cpp.

◆ document() [5/9]

xml::document::document ( const node n)
explicit

Create a new XML document and set the root node.

Parameters
nThe node to use as the root node. n will be copied.
Author
Peter Jones

Definition at line 406 of file document.cpp.

References n.

◆ document() [6/9]

xml::document::document ( const document_proxy doc_proxy)

Creates a new XML document using the document_proxy, i.e.

essentially xslt results. (see CXX-2458)

Parameters
doc_proxyXSLT results
Author
Denis Vakatov

Definition at line 412 of file document.cpp.

References xml::document_proxy::release(), xml::document_proxy::result_, set_doc_data_from_xslt(), and xml::document_proxy::style_sheet_.

◆ document() [7/9]

xml::document::document ( std::istream &  stream,
error_messages messages,
warnings_as_errors_type  how = type_warnings_not_errors 
)

Creates a new XML document by parsing the given XML from a stream.

Parameters
streamThe stream to read XML document from.
messagesA pointer to the object where all the warnings are collected. If NULL then no messages will be collected.
howHow to treat warnings (default: warnings are not treated as errors). If warnings are treated as errors then an exception is thrown in case of both errors and/or warnings. If warnings are not treated as errors then an exception will be thrown only when there are errors.
Exceptions
Throwsxml::parser_exception in case of parsing errors and std::exception in case of other problems.
Author
Denis Vakatov

Definition at line 422 of file document.cpp.

References buffer, xml::impl::clear_https_messages(), xml::impl::collect_https_messages(), const_buffer_size, xml::error_messages::get_messages(), is_failure(), NULL, pimpl_, set_doc_data(), set_parser_context_options(), and xml::error_message::type_error.

◆ ~document()

xml::document::~document ( void  )
virtual

Clean up after an XML document object.

Author
Peter Jones

Definition at line 534 of file document.cpp.

References NULL.

◆ document() [8/9]

xml::document::document ( const document other)

Copy construct a new XML document.

The new document will be an exact copy of the original.

Parameters
otherThe other document object to copy from.
Author
Peter Jones

Definition at line 497 of file document.cpp.

◆ document() [9/9]

xml::document::document ( document &&  other)

Moving constructor.

Parameters
otherThe other document.

Definition at line 513 of file document.cpp.

References NULL.

Member Function Documentation

◆ assign()

xml::document & xml::document::assign ( const document other)

Copy another document object into this one.

This document object will be an exact copy of the other document after the assignement.

Parameters
otherThe document to copy from.
Returns
*this.
Author
Denis Vakatov

Definition at line 507 of file document.cpp.

References swap(), and tmp.

◆ begin() [1/2]

xml::node::iterator xml::document::begin ( void  )

Get an iterator to the first child node of this document.

If what you really wanted was the root node (the first element) you should use the get_root_node() member function instead.

Returns
A xml::node::iterator that points to the first child node.
An end iterator if there are no children in this document
Author
Peter Jones

Definition at line 695 of file document.cpp.

Referenced by CDoiLookup::LookupIsojta().

◆ begin() [2/2]

xml::node::const_iterator xml::document::begin ( void  ) const

Get a const_iterator to the first child node of this document.

If what you really wanted was the root node (the first element) you should use the get_root_node() member function instead.

Returns
A xml::node::const_iterator that points to the first child node.
An end const_iterator if there are no children in this document.
Author
Peter Jones

Definition at line 699 of file document.cpp.

◆ end() [1/2]

xml::node::iterator xml::document::end ( void  )

Get an iterator that points one past the last child node for this document.

Returns
An end xml::node::iterator.
Author
Peter Jones

Definition at line 703 of file document.cpp.

Referenced by CDoiLookup::LookupIsojta().

◆ end() [2/2]

xml::node::const_iterator xml::document::end ( void  ) const

Get a const_iterator that points one past the last child node for this document.

Returns
An end xml::node::const_iterator.
Author
Peter Jones

Definition at line 707 of file document.cpp.

◆ erase() [1/2]

xml::node::iterator xml::document::erase ( node::iterator  first,
node::iterator  last 
)

Erase all nodes in the given range, from frist to last.

This will invalidate any iterators that point to the nodes to be erased, or any pointers or references to those nodes.

Do not remove the root node using this member function. The same rules that apply to push_back apply here. If you try to erase the root node, an exception will be thrown.

Parameters
firstThe first node in the range to be removed.
lastAn iterator that points one past the last node to erase. Think xml::node::end().
Returns
An iterator that points to the node after the last one being erased.
See also
xml::document::push_back
Author
Peter Jones

Definition at line 768 of file document.cpp.

References first(), and last().

◆ erase() [2/2]

xml::node::iterator xml::document::erase ( node::iterator  to_erase)

Erase the node that is pointed to by the given iterator.

The node and all its children will be removed from this node. This will invalidate any iterators that point to the node to be erased, or any pointers or references to that node.

Do not remove the root node using this member function. The same rules that apply to push_back apply here. If you try to erase the root node, an exception will be thrown.

Parameters
to_eraseAn iterator that points to the node to be erased.
Returns
An iterator that points to the node after the one being erased.
See also
xml::document::push_back
Author
Peter Jones

Definition at line 759 of file document.cpp.

References xml::node::iterator::get_raw_node(), xml::node::get_type(), xml::impl::node_erase(), and xml::node::type_element.

◆ get_doc_data()

void * xml::document::get_doc_data ( void  )
private

◆ get_doc_data_read_only()

void * xml::document::get_doc_data_read_only ( void  ) const
private

Definition at line 1024 of file document.cpp.

Referenced by xslt::stylesheet::apply().

◆ get_encoding()

const std::string & xml::document::get_encoding ( void  ) const

Get the XML encoding for this document.

The default encoding is ISO-8859-1.

Returns
The encoding string.
Author
Peter Jones

Definition at line 571 of file document.cpp.

◆ get_external_subset()

const xml::dtd & xml::document::get_external_subset ( void  ) const

Provides the DTD data that is referenced from an external source, such as a file or URL.

Returns
The external document DTD
Exceptions
Throwsexception if the document does not have the external DTD.
Author
: Sergey Satskiy, NCBI

Definition at line 618 of file document.cpp.

◆ get_internal_subset()

const xml::dtd & xml::document::get_internal_subset ( void  ) const

Provides the DTD data that is declared within the XML document itself.

Returns
The internal document DTD
Exceptions
Throwsexception if the document does not have the internal DTD.
Author
: Sergey Satskiy, NCBI

Definition at line 607 of file document.cpp.

◆ get_is_standalone()

bool xml::document::get_is_standalone ( void  ) const

Find out if the current document is a standalone document.

For generated documents, this will be the default. For parsed documents this will be set based on the XML processing instruction.

Returns
True if this document is standalone.
False if this document is not standalone.
Author
Peter Jones

Definition at line 590 of file document.cpp.

◆ get_root_node() [1/2]

xml::node & xml::document::get_root_node ( void  )

Get a reference to the root node of this document.

If no root node has been set, the returned node will be a blank node. You should take caution to use a reference so that you don't copy the whole node tree!

Returns
A reference to the root node.
Author
Peter Jones

Definition at line 544 of file document.cpp.

References xml::node::set_node_data().

◆ get_root_node() [2/2]

const xml::node & xml::document::get_root_node ( void  ) const

◆ get_version()

const std::string & xml::document::get_version ( void  ) const

Get the XML version for this document.

For generated documents, the version will be the default. For parsed documents, this will be the version from the XML processing instruction.

Returns
The XML version string for this document.
Author
Peter Jones

Definition at line 553 of file document.cpp.

◆ has_external_subset()

bool xml::document::has_external_subset ( void  ) const

Test to see if this document has an external subset.

That is, it references a DTD from an external source, such as a file or URL.

Returns
True if this document has an external subset.
False otherwise.
Author
Peter Jones

Definition at line 614 of file document.cpp.

◆ has_internal_subset()

bool xml::document::has_internal_subset ( void  ) const

Test to see if this document has an internal subset.

That is, DTD data that is declared within the XML document itself.

Returns
True if this document has an internal subset.
False otherwise.
Author
Peter Jones

Definition at line 603 of file document.cpp.

◆ insert() [1/2]

xml::node::iterator xml::document::insert ( const node n)

Insert a new child node.

The new node will be inserted at the end of the child list. This is similar to the xml::node::push_back member function except that an iterator to the inserted node is returned.

The rules from the push_back member function apply here. Don't add a node of type element.

Parameters
nThe node to insert as a child of this document.
Returns
An iterator that points to the newly inserted node.
See also
xml::document::push_back
Author
Peter Jones

Definition at line 720 of file document.cpp.

References xml::node::get_node_data(), n, xml::impl::node_insert(), and xml::node::type_element.

◆ insert() [2/2]

xml::node::iterator xml::document::insert ( node::iterator  position,
const node n 
)

Insert a new child node.

The new node will be inserted before the node pointed to by the given iterator.

The rules from the push_back member function apply here. Don't add a node of type element.

Parameters
positionAn iterator that points to the location where the new node should be inserted (before it).
nThe node to insert as a child of this document.
Returns
An iterator that points to the newly inserted node.
See also
xml::document::push_back
Author
Peter Jones

Definition at line 731 of file document.cpp.

References xml::node::get_node_data(), xml::node::iterator::get_raw_node(), n, xml::impl::node_insert(), and xml::node::type_element.

◆ is_failure()

bool xml::document::is_failure ( error_messages messages,
warnings_as_errors_type  how 
) const
private

◆ operator=() [1/2]

xml::document & xml::document::operator= ( const document other)

Copy another document object into this one using the assignment operator.

This document object will be an exact copy of the other document after the assignement.

Parameters
otherThe document to copy from.
Returns
*this.
Author
Peter Jones

Definition at line 501 of file document.cpp.

References swap(), and tmp.

Referenced by xml::libxml2_document::operator=().

◆ operator=() [2/2]

xml::document & xml::document::operator= ( document &&  other)

Moving assignment.

Parameters
otherThe other document.

Definition at line 519 of file document.cpp.

References NULL, and pimpl_.

◆ process_xinclude()

bool xml::document::process_xinclude ( void  )

Walk through the document and expand <xi:include> elements.

For more information, please see the w3c recomendation for XInclude. http://www.w3.org/2001/XInclude.

The return value of this function may change to int after a bug has been fixed in libxml2 (xmlXIncludeDoProcess).

Returns
False if there was an error with substitutions.
True if there were no errors (with or without substitutions).
Author
Peter Jones
Daniel Evison

Definition at line 598 of file document.cpp.

◆ push_back()

void xml::document::push_back ( const node child)

Add a child xml::node to this document.

You should not add a element type node, since there can only be one root node. This member function is only useful for adding processing instructions, comments, etc.. If you do try to add a node of type element, an exception will be thrown.

Parameters
childThe child xml::node to add.
Author
Peter Jones

Definition at line 711 of file document.cpp.

References xml::node::get_node_data(), xml::node::get_type(), xml::impl::node_insert(), and xml::node::type_element.

◆ release_doc_data()

void * xml::document::release_doc_data ( void  )
private

◆ replace()

xml::node::iterator xml::document::replace ( node::iterator  old_node,
const node new_node 
)

Replace the node pointed to by the given iterator with another node.

The old node will be removed, including all its children, and replaced with the new node. This will invalidate any iterators that point to the node to be replaced, or any pointers or references to that node.

Do not replace this root node with this member function. The same rules that apply to push_back apply here. If you try to replace a node of type element, an exception will be thrown.

Parameters
old_nodeAn iterator that points to the node that should be removed.
new_nodeThe node to put in old_node's place.
Returns
An iterator that points to the new node.
See also
xml::document::push_back
Author
Peter Jones

Definition at line 744 of file document.cpp.

References xml::node::get_node_data(), xml::node::iterator::get_raw_node(), xml::node::get_type(), xml::impl::node_replace(), and xml::node::type_element.

◆ save_to_file()

bool xml::document::save_to_file ( const char *  filename,
save_option_flags  flags = save_op_default 
) const

Convert the XML document tree into XML text data and place it into the given filename.

Parameters
filenameThe name of the file to place the XML text data into.
flagsBitwise mask of the save options. Does not affect XSLT result documents.
See also
xml::save_option
Note
compression part of the options is currently ignored.
Returns
True if the data was saved successfully.
False otherwise.
Author
Peter Jones and Sergey Satskiy, NCBI

Definition at line 959 of file document.cpp.

References xml::impl::convert_to_libxml2_save_options(), flags, xslt::impl::is_xml_output_method(), xslt::impl::save_to_file(), and swap().

◆ save_to_stream()

void xml::document::save_to_stream ( std::ostream &  stream,
save_option_flags  flags = save_op_default 
) const

Convert the XML document tree into XML text data and then insert it into the given stream.

Parameters
streamThe stream to insert the XML into.
flagsBitwise mask of the save options. Does not affect XSLT result documents.
Note
compression part of the options is currently ignored.
See also
xml::save_option
Author
Sergey Satskiy, NCBI

Definition at line 922 of file document.cpp.

References xml::impl::convert_to_libxml2_save_options(), flags, xslt::impl::is_xml_output_method(), NULL, xml::impl::save_to_stream_cb(), xslt::impl::save_to_string(), string, and swap().

Referenced by xml::operator<<(), CFormatGuessApp::Run(), CGapStatsApplication::x_PrintHistogram(), CGapStatsApplication::x_PrintSeqsForGapLengths(), and CGapStatsApplication::x_PrintSummaryView().

◆ save_to_string()

void xml::document::save_to_string ( std::string s,
save_option_flags  flags = save_op_default 
) const

Convert the XML document tree into XML text data and place it into the given string.

Parameters
sThe string to place the XML text data (the string is cleared)
flagsBitwise mask of the save options. Does not affect XSLT result. documents.
See also
xml::save_option
Note
compression part of the options is currently ignored.
Author
Peter Jones and Sergey Satskiy, NCBI

Definition at line 775 of file document.cpp.

References xml::impl::convert_to_libxml2_save_options(), flags, xslt::impl::is_xml_output_method(), NULL, xslt::impl::save_to_string(), xml::impl::save_to_string_cb(), and swap().

Referenced by BOOST_AUTO_TEST_CASE(), and save_to_string_canonical().

◆ save_to_string_canonical()

void xml::document::save_to_string_canonical ( std::string str,
canonicalization_option  c14n_option,
canonicalization_comments_option  comments_option,
canonicalization_format_option  format_option,
canonicalization_node_sort_option  node_sort_option 
) const

Convert the XML document tree into XML text data and place it into the given string.

Parameters
strThe string to place the XML text data (the string is cleared)
c14n_optionCanonicalization mode
comments_optionComments option (strip or keep)
format_optionFormat option (let libxml2 format the document or not)
node_sort_optionTo sort or not the nodes before the canonicalization
Exceptions
throwsxml::exception in case of problems
Note
: the member has a significant memory and CPU footprint.

Definition at line 810 of file document.cpp.

References c14n_op_to_libxml2_op(), xml::impl::doc_impl::doc_, flags, get_root_node(), xml::node::get_type(), xslt::impl::is_xml_output_method(), xml::keep_comments, NULL, pimpl_, remove_comments_recursively(), result, xml::save_op_default, xml::save_op_no_decl, xml::save_op_no_format, save_to_string(), xslt::impl::save_to_string(), ncbi::grid::netcache::search::fields::size, xml::sort_attr_and_ns, xml::sort_attr_and_ns_no_decl, sort_attributes_recursively(), sort_namespace_definitions_recursively(), sort_node_recursively(), str(), string, xml::strip_comments, xml::node::type_comment, xml::type_warnings_not_errors, xml::with_formatting, xml::with_node_sorting, and xml::without_formatting.

Referenced by xml::node::save_to_string_canonical().

◆ set_doc_data()

void xml::document::set_doc_data ( void *  data)
private

◆ set_doc_data_from_xslt()

void xml::document::set_doc_data_from_xslt ( void *  data,
void *  ssheet 
)
private

Definition at line 1010 of file document.cpp.

References data.

Referenced by document().

◆ set_encoding()

void xml::document::set_encoding ( const char *  encoding)

Set the XML encoding string.

If you don't set this, it will default to ISO-8859-1.

Parameters
encodingThe XML encoding to use.
Author
Peter Jones
Dmitriy Nikitinskiy

Definition at line 577 of file document.cpp.

Referenced by CTabDelimitedValidator::_ReportXML(), and PrintBioseqXML().

◆ set_external_subset()

void document::set_external_subset ( const dtd dtd_)

Sets the document external subset.

Parameters
dtd_use this dtd to set as an external subset
Exceptions
Throwsexception in case of problems.
Author
Sergey Satskiy, NCBI

Definition at line 667 of file document.cpp.

References copy(), xml::impl::doc_impl::doc_, xml::dtd::get_raw_pointer(), NULL, and pimpl_.

◆ set_is_standalone()

void xml::document::set_is_standalone ( bool  sa)

Set the standalone flag.

This will show up in the XML output in the correct processing instruction.

Parameters
saWhat to set the standalone flag to.
Author
Peter Jones

Definition at line 594 of file document.cpp.

Referenced by CTabDelimitedValidator::_ReportXML(), and PrintBioseqXML().

◆ set_root_node()

void xml::document::set_root_node ( const node n)

Set the root node to the given node.

A full copy is made and stored in the document object.

Parameters
nThe new root node to use.
Author
Peter Jones

Definition at line 549 of file document.cpp.

References n.

◆ set_version()

void xml::document::set_version ( const char *  version)

Set the XML version number for this document.

This version string will be used when generating the XML output.

Parameters
versionThe version string to use, like "1.0".
Author
Peter Jones

Definition at line 557 of file document.cpp.

References version.

◆ size()

xml::document::size_type xml::document::size ( void  ) const

Returns the number of child nodes of this document.

This will always be at least one, since all xmlwrapp documents must have a root node. This member function is useful to find out how many document children there are, including processing instructions, comments, etc.

Returns
The number of children nodes that this document has.
Author
Peter Jones

Definition at line 683 of file document.cpp.

References first(), and last().

Referenced by document().

◆ swap()

void xml::document::swap ( document other)

Swap one xml::document object for another.

Parameters
otherThe other document to swap
Author
Peter Jones

Definition at line 530 of file document.cpp.

References pimpl_, and swap().

Referenced by CRfamTool::CRfamTool(), CSeqUtils::ESearchQuery(), s_ELinkQuery(), CEutilsClient::x_LinkOutOnce(), and CEutilsClient::x_SummaryOnce().

◆ validate() [1/3]

bool document::validate ( const dtd dtd_,
error_messages messages_,
warnings_as_errors_type  how = type_warnings_are_errors 
) const

Validate this document against the given DTD.

If the document is valid, this member function will return true.

The warnings and error messages are collected in the given xml::error_messages object.

Parameters
dtd_A DTD constructed from a file or URL or empty DTD. The empty DTD is for validating the document against the internal DTD.
messages_A pointer to the object where the warnings and error messages are collected. If NULL is passed then no messages will be collected.
howHow to treat warnings (default: warnings are treated as errors). If warnings are treated as errors false is returned in case of both errors and/or warnings. If warnings are not treated as errors then false is returned only when there are errors.
Returns
True if the document is valid.
False if there was a problem with the DTD or XML doc.
Author
Sergey Satskiy, NCBI

Definition at line 657 of file document.cpp.

References xml::dtd::validate().

◆ validate() [2/3]

bool document::validate ( const schema schema_,
error_messages messages_,
warnings_as_errors_type  how = type_warnings_are_errors 
) const

Validate this document against the given XSD schema.

If the document is valid, this member function will return true.

The warnings and error messages are collected in the given xml::error_messages object.

Parameters
xsd_schemaA constructed XSD schema.
messages_A pointer to the object where the warnings and error messages are collected. If NULL is passed then no messages will be collected.
howHow to treat warnings (default: warnings are treated as errors). If warnings are treated as errors false is returned in case of both errors and/or warnings. If warnings are not treated as errors then false is returned only when there are errors.
Returns
True if the document is valid.
False if there was a problem with the XML doc.
Author
Sergey Satskiy, NCBI

Definition at line 662 of file document.cpp.

References xml::schema::validate().

◆ validate() [3/3]

bool document::validate ( error_messages messages_ = NULL,
warnings_as_errors_type  how = type_warnings_are_errors 
) const

Validate this document against the DTD that has been attached to it.

This would happen at parse time if there was a !DOCTYPE definition. If the DTD is valid, and the document is valid, this member function will return true.

The warnings and error messages are collected in the given xml::error_messages object.

Parameters
messages_A pointer to the object where the warnings and error messages are collected. If NULL is passed then no messages will be collected.
howHow to treat warnings (default: warnings are treated as errors). If warnings are treated as errors false is returned in case of both errors and/or warnings. If warnings are not treated as errors then false is returned only when there are errors.
Returns
True if the document is valid.
False if there was a problem with the XML doc.
Author
Sergey Satskiy, NCBI

Definition at line 625 of file document.cpp.

References xml::impl::clear_https_messages(), xml::impl::collect_https_messages(), xml::impl::doc_impl::doc_, xml::error_messages::get_messages(), xml::error_messages::has_errors(), xml::error_messages::has_warnings(), pimpl_, and xml::type_warnings_are_errors.

◆ void ::xslt_ext_element_cb()

xml::document::void ::xslt_ext_element_cb ( void *  ,
void *  ,
void *  ,
void *   
)
private

◆ void ::xslt_ext_func_cb()

xml::document::void ::xslt_ext_func_cb ( void *  ,
int   
)
private

Friends And Related Function Documentation

◆ dtd

friend class dtd
friend

Definition at line 782 of file document.hpp.

◆ libxml2_document

friend class libxml2_document ( void  )
friend

Definition at line 783 of file document.hpp.

◆ node

friend class node
friend

Definition at line 784 of file document.hpp.

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const document doc 
)
friend

Convert the XML document tree into XML text data and then insert it into the given stream.

Parameters
streamThe stream to insert the XML into.
docThe document to insert.
Returns
The stream from the first parameter.
Author
Peter Jones

◆ schema

friend class schema
friend

Definition at line 781 of file document.hpp.

◆ xslt::stylesheet

friend class xslt::stylesheet
friend

Definition at line 780 of file document.hpp.

Member Data Documentation

◆ pimpl_

impl::doc_impl* xml::document::pimpl_
private

The documentation for this class was generated from the following files:
Modified on Sat May 25 14:17:30 2024 by modify_doxy.py rev. 669887