NCBI C++ ToolKit
|
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>
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... | |
document & | assign (const document &other) |
Copy another document object into this one. More... | |
virtual | ~document (void) |
Clean up after an XML document object. More... | |
const node & | get_root_node (void) const |
Get a reference to the root node of this document. More... | |
node & | get_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::string & | get_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::string & | get_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 dtd & | get_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 dtd & | get_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... | |
document & | operator= (const document &other) |
Copy another document object into this one using the assignment operator. More... | |
document (document &&other) | |
Moving constructor. More... | |
document & | operator= (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_impl * | pimpl_ |
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... | |
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.
typedef std::size_t xml::document::size_type |
size type
Definition at line 83 of file document.hpp.
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".
Definition at line 225 of file document.cpp.
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.
filename | The XML file name. |
messages | A pointer to the object where all the warnings are collected. If NULL then no messages will be collected. |
how | How 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. |
Throws | xml::parser_exception in case of parsing errors and std::exception in case of other problems. |
Definition at line 286 of file document.cpp.
References xml::impl::clear_https_messages(), xml::impl::collect_https_messages(), xml::error_messages::get_messages(), xml::init::get_remove_whitespace(), is_failure(), msg(), NULL, pimpl_, set_doc_data(), test, xml::error_message::type_fatal_error, and xmlSAXParseFileWithData_Custom().
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.
data | The XML memory buffer. |
size | Size of the memory buffer. |
messages | A pointer to the object where all the warnings are collected. If NULL then no messages will be collected. |
how | How 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. |
Throws | xml::parser_exception in case of parsing errors and std::exception in case of other problems. |
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(), xml::init::get_remove_whitespace(), is_failure(), pimpl_, set_doc_data(), set_parser_context_options(), size(), and xml::size_t_to_int_conversion().
|
explicit |
Create a new XML document and set the name of the root element to the given text.
root_name | What to set the name of the root element to. |
Definition at line 402 of file document.cpp.
Create a new XML document and set the root node.
n | The node to use as the root node. n will be copied. |
Definition at line 406 of file document.cpp.
References n.
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)
doc_proxy | XSLT results |
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_.
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.
stream | The stream to read XML document from. |
messages | A pointer to the object where all the warnings are collected. If NULL then no messages will be collected. |
how | How 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. |
Throws | xml::parser_exception in case of parsing errors and std::exception in case of other problems. |
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(), xml::init::get_remove_whitespace(), is_failure(), NULL, pimpl_, set_doc_data(), set_parser_context_options(), and xml::error_message::type_error.
|
virtual |
Clean up after an XML document object.
Definition at line 534 of file document.cpp.
References NULL.
Copy construct a new XML document.
The new document will be an exact copy of the original.
other | The other document object to copy from. |
Definition at line 497 of file document.cpp.
xml::document::document | ( | document && | other | ) |
Moving constructor.
other | The other document. |
Definition at line 513 of file document.cpp.
References NULL.
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.
other | The document to copy from. |
Definition at line 507 of file document.cpp.
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.
Definition at line 695 of file document.cpp.
Referenced by CDoiLookup::LookupIsojta().
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.
Definition at line 699 of file document.cpp.
xml::node::iterator xml::document::end | ( | void | ) |
Get an iterator that points one past the last child node for this document.
Definition at line 703 of file document.cpp.
Referenced by CDoiLookup::LookupIsojta().
xml::node::const_iterator xml::document::end | ( | void | ) | const |
Get a const_iterator that points one past the last child node for this document.
Definition at line 707 of file document.cpp.
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.
first | The first node in the range to be removed. |
last | An iterator that points one past the last node to erase. Think xml::node::end(). |
Definition at line 768 of file document.cpp.
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.
to_erase | An iterator that points to the node to be erased. |
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.
|
private |
Definition at line 1020 of file document.cpp.
Referenced by xml::libxml2_document::get_raw_doc(), and xslt::stylesheet::stylesheet().
|
private |
Definition at line 1024 of file document.cpp.
Referenced by xslt::stylesheet::apply().
const std::string & xml::document::get_encoding | ( | void | ) | const |
Get the XML encoding for this document.
The default encoding is ISO-8859-1.
Definition at line 571 of file document.cpp.
Provides the DTD data that is referenced from an external source, such as a file or URL.
Throws | exception if the document does not have the external DTD. |
Definition at line 618 of file document.cpp.
Provides the DTD data that is declared within the XML document itself.
Throws | exception if the document does not have the internal DTD. |
Definition at line 607 of file document.cpp.
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.
Definition at line 590 of file document.cpp.
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!
Definition at line 544 of file document.cpp.
References xml::node::set_node_data().
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!
Definition at line 539 of file document.cpp.
References xml::node::set_node_data().
Referenced by CTabDelimitedValidator::_ReportXML(), BOOST_AUTO_TEST_CASE(), CSeqUtils::GetAssmAccs_Gi(), CSeqUtils::GetAssmIds_GIChr(), GetBiosampleStatus(), CRfamTool::GetModelByAccession(), CRfamTool::GetModelByIdentification(), CAssemblyInfo::IsSameAssembly(), PrintBioseqXML(), ProcessBulkBioSample(), s_ELinkQuery(), s_ESearchQuery(), save_to_string_canonical(), CEntrezSearchJob::x_DoSearch(), CNAUtils::x_GetAllGIs(), CNAUtils::x_GetAllNAIdsWithContext(), CAssemblyInfo::x_GetAssmInfo(), CNAUtils::x_GetNAEntrezLinks(), CNAUtils::x_ParseNAMetaData(), CGapStatsApplication::x_PrintHistogram(), CGapStatsApplication::x_PrintSeqsForGapLengths(), and CGapStatsApplication::x_PrintSummaryView().
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.
Definition at line 553 of file document.cpp.
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.
Definition at line 614 of file document.cpp.
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.
Definition at line 603 of file document.cpp.
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.
n | The node to insert as a child of this document. |
Definition at line 720 of file document.cpp.
References xml::node::get_node_data(), n, xml::impl::node_insert(), and xml::node::type_element.
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.
position | An iterator that points to the location where the new node should be inserted (before it). |
n | The node to insert as a child of this document. |
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.
|
private |
Definition at line 1040 of file document.cpp.
References xml::error_messages::has_errors(), xml::error_messages::has_fatal_errors(), xml::error_messages::has_warnings(), and xml::type_warnings_are_errors.
Referenced by document().
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.
other | The document to copy from. |
Definition at line 501 of file document.cpp.
Referenced by xml::libxml2_document::operator=().
xml::document & xml::document::operator= | ( | document && | other | ) |
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).
Definition at line 598 of file document.cpp.
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.
child | The child xml::node to add. |
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.
Referenced by BOOST_AUTO_TEST_CASE().
|
private |
Definition at line 1028 of file document.cpp.
Referenced by xml::node::save_to_string_canonical(), and xslt::stylesheet::stylesheet().
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.
old_node | An iterator that points to the node that should be removed. |
new_node | The node to put in old_node's place. |
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.
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.
filename | The name of the file to place the XML text data into. |
flags | Bitwise mask of the save options. Does not affect XSLT result documents. |
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().
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.
stream | The stream to insert the XML into. |
flags | Bitwise mask of the save options. Does not affect XSLT result documents. |
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().
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.
s | The string to place the XML text data (the string is cleared) |
flags | Bitwise mask of the save options. Does not affect XSLT result. documents. |
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().
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.
str | The string to place the XML text data (the string is cleared) |
c14n_option | Canonicalization mode |
comments_option | Comments option (strip or keep) |
format_option | Format option (let libxml2 format the document or not) |
node_sort_option | To sort or not the nodes before the canonicalization |
throws | xml::exception in case of problems |
Definition at line 810 of file document.cpp.
References c14n_op_to_libxml2_op(), xml::impl::doc_impl::doc_, flags, xml::init::get_remove_whitespace(), get_root_node(), xml::node::get_type(), xslt::impl::is_xml_output_method(), xml::keep_comments, NULL, pimpl_, remove_comments_recursively(), xml::init::remove_whitespace(), 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().
|
private |
Definition at line 998 of file document.cpp.
References data.
Referenced by document(), xml::libxml2_document::libxml2_document(), xml::node::save_to_string_canonical(), xml::libxml2_document::set_raw_doc(), xslt_ext_element_cb(), and xslt_ext_func_cb().
|
private |
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.
encoding | The XML encoding to use. |
Definition at line 577 of file document.cpp.
Referenced by CTabDelimitedValidator::_ReportXML(), and PrintBioseqXML().
Sets the document external subset.
dtd_ | use this dtd to set as an external subset |
Throws | exception in case of problems. |
Definition at line 667 of file document.cpp.
References copy(), xml::impl::doc_impl::doc_, xml::dtd::get_raw_pointer(), NULL, and pimpl_.
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.
sa | What to set the standalone flag to. |
Definition at line 594 of file document.cpp.
Referenced by CTabDelimitedValidator::_ReportXML(), and PrintBioseqXML().
Set the root node to the given node.
A full copy is made and stored in the document object.
n | The new root node to use. |
Definition at line 549 of file document.cpp.
References n.
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.
version | The version string to use, like "1.0". |
Definition at line 557 of file document.cpp.
References dtl::version.
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.
Definition at line 683 of file document.cpp.
References first(), and last().
Referenced by document().
void xml::document::swap | ( | document & | other | ) |
Swap one xml::document object for another.
other | The other document to swap |
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().
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.
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. |
how | How 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. |
Definition at line 657 of file document.cpp.
References xml::dtd::validate().
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.
xsd_schema | A 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. |
how | How 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. |
Definition at line 662 of file document.cpp.
References xml::schema::validate().
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.
messages_ | A pointer to the object where the warnings and error messages are collected. If NULL is passed then no messages will be collected. |
how | How 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. |
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.
|
private |
|
private |
|
friend |
Definition at line 782 of file document.hpp.
|
friend |
Definition at line 783 of file document.hpp.
|
friend |
Definition at line 784 of file document.hpp.
Convert the XML document tree into XML text data and then insert it into the given stream.
stream | The stream to insert the XML into. |
doc | The document to insert. |
|
friend |
Definition at line 781 of file document.hpp.
|
friend |
Definition at line 780 of file document.hpp.
|
private |
Definition at line 770 of file document.hpp.
Referenced by document(), xml::libxml2_document::get_ownership(), operator=(), save_to_string_canonical(), set_external_subset(), xml::libxml2_document::set_ownership(), swap(), xml::dtd::validate(), xml::schema::validate(), validate(), xslt_ext_element_cb(), and xslt_ext_func_cb().