Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/classxml_1_1node.html below:
NCBI C++ ToolKit: xml::node Class Reference
Search Toolkit Book for xml::node
The xml::node class is used to hold information about one XML node. More...
#include <misc/xmlwrapp/node.hpp>
enum node_type {
type_element , type_text , type_cdata , type_pi ,
type_comment , type_entity , type_entity_ref , type_xinclude ,
type_document , type_document_type , type_document_frag , type_notation ,
type_dtd , type_dtd_element , type_dtd_attribute , type_dtd_entity ,
type_dtd_namespace
} enum for the different types of XML nodes More...
enum ns_definition_adding_type { type_replace_if_exists , type_throw_if_exists } enum for policies of adding namespace definitions More...
enum ns_definition_erase_type { type_ns_def_erase_if_not_used , type_ns_def_erase_enforce } enum to specify how to remove namespace definitions More...
enum effective_ns_list_type { type_ns_all , type_ns_only_default , type_ns_only_non_default } enum to specify what namespaces to include into the list of the node effective namespaces More...
typedef std::size_t size_type size type More...
node (void) Construct a new blank xml::node. More...
node (const char *name) Construct a new xml::node and set the name of the node. More...
node (const char *name, const char *content) Construct a new xml::node given a name and content. More...
node (cdata cdata_info) Construct a new xml::node that is of type_cdata. More...
node (comment comment_info) Construct a new xml::node that is of type_comment. More...
node (pi pi_info) Construct a new xml::node that is of type_pi. More...
node (text text_info) Construct a new xml::node that is of type_text. More...
node * detached_copy (void) const Create a copy of the node which is detached from the document. More...
node & assign (const node &other) Copy another node object into this one. More...
virtual ~node (void) Class destructor. More...
void set_name (const char *name) Set the name of this xml::node. More...
const char * get_name (void) const Get the name of this xml::node. More...
void set_content (const char *content) Set the content of a node. More...
void set_raw_content (const char *raw_content) Set the raw content of a node. More...
const char * get_content (void) const Get the content for this text node. More...
node_type get_type (void) const Get this node's "type". More...
xml::attributes & get_attributes (void) Get the list of attributes. More...
const xml::attributes & get_attributes (void) const Get the list of attributes. More...
attributes::iterator find_attribute (const char *name, const ns *nspace=NULL) Search for a node attribute. More...
attributes::const_iterator find_attribute (const char *name, const ns *nspace=NULL) const Search for a node attribute. More...
ns get_namespace (ns::ns_safety_type type=ns::type_safe_ns) const Get the namespace of this xml::node. More...
ns_list_type get_namespace_definitions (ns::ns_safety_type type=ns::type_safe_ns) const Get the namespaces defined at this xml::node. More...
ns set_namespace (const ns &name_space) Set the node namespace. More...
ns set_namespace (const char *prefix) Set the node namespace. More...
ns add_namespace_definition (const ns &name_space, ns_definition_adding_type type) Add namespace definition to the node. More...
void add_namespace_definitions (const ns_list_type &name_spaces, ns_definition_adding_type type) Add namespace definitions to the node. More...
void erase_namespace_definition (const char *prefix, ns_definition_erase_type how=type_ns_def_erase_if_not_used) Remove the node namespace definition. More...
void erase_namespace (void) Remove the node namespace. More...
ns lookup_namespace (const char *prefix, ns::ns_safety_type type=ns::type_safe_ns) const Look up a namespace with the given prefix. More...
void erase_duplicate_ns_defs (void) Erase duplicate namespace definitions. More...
void erase_unused_ns_defs (void) Erase unused namespace definitions. More...
std::string get_path (void) const Get the node path. More...
bool is_text (void) const Find out if this node is a text node or sometiming like a text node, CDATA for example. More...
void push_back (const node &child) Add a child xml::node to this node. More...
void swap (node &other) Swap this node with another one. More...
size_type size (void) const Returns the number of childer this nodes has. More...
bool empty (void) const Find out if this node has any children. More...
iterator begin (void) Get an iterator that points to the beginning of this node's children. More...
const_iterator begin (void) const Get a const_iterator that points to the beginning of this node's children. More...
iterator end (void) Get an iterator that points one past the last child for this node. More...
const_iterator end (void) const Get a const_iterator that points one past the last child for this node. More...
iterator self (void) Get an iterator that points back at this node. More...
const_iterator self (void) const Get a const_iterator that points back at this node. More...
bool is_root (void) const Find out if this node is a root one, i.e. More...
iterator parent (void) Get an iterator that points at the parent of this node. More...
const_iterator parent (void) const Get a const_iterator that points at the parent of this node. More...
iterator find (const char *name, const ns *nspace=NULL) Find the first child node that has the given name and namespace. More...
const_iterator find (const char *name, const ns *nspace=NULL) const Find the first child node that has the given name and namespace. More...
iterator find (const char *name, const iterator &start, const ns *nspace=NULL) Find the first child node, starting with the given iterator, that has the given name and namespace. More...
const_iterator find (const char *name, const const_iterator &start, const ns *nspace=NULL) const Find the first child node, starting with the given const_iterator, that has the given name and namespace. More...
node_set run_xpath_query (const xpath_expression &expr) Run the given XPath query. More...
const node_set run_xpath_query (const xpath_expression &expr) const Run the given XPath query. More...
node_set run_xpath_query (const char *expr) Run the given XPath query. More...
const node_set run_xpath_query (const char *expr) const Run the given XPath query. More...
iterator insert (const node &n) Insert a new child node. More...
iterator insert (const iterator &position, const node &n) Insert a new child node. More...
iterator replace (const iterator &old_node, const node &new_node) Replace the node pointed to by the given iterator with another node. More...
iterator erase (const iterator &to_erase) Erase the node that is pointed to by the given iterator. More...
iterator erase (iterator first, const iterator &last) Erase all nodes in the given range, from frist to last. More...
size_type erase (const char *name) Erase all children nodes with the given name. More...
void clear (void) Erase all children nodes. More...
void sort (const char *node_name, const char *attr_name) Sort all the children nodes of this node using one of thier attributes. More...
template<typename T > void sort (T compare) Sort all the children nodes of this node using the given comparison function object. More...
void save_to_string (std::string &xml, save_option_flags flags=save_op_default) const Convert the node and all its children into XML text and set the given string to that text. 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 node and all its children into XML text and set the given string to that text. More...
void append_to_string (std::string &xml, save_option_flags flags=save_op_default) const Convert the node and all its children into XML text and set the given string to that text. More...
ns_list_type get_effective_namespaces (effective_ns_list_type which=type_ns_all) const Provides a list of effective namespaces for the node. More...
void sort_namespace_definitions (void) Sorts the namespace definitions in the node in place. More...
node (const node &other) Construct a new xml::node by copying another xml::node. More...
node & operator= (const node &other) Make this node equal to some other node via assignment. More...
node (node &&other) Moving constructor. More...
node & operator= (node &&other) Moving assignment. More...
node (int) void set_node_data (void *data) void * get_node_data (void) const void * release_node_data (void) node_set convert_to_nset (void *) const void sort_fo (impl::cbfo_node_compare &fo) ns add_namespace_def (const char *uri, const char *prefix) ns add_matched_namespace_def (void *libxml2RawNamespace, const char *uri, ns_definition_adding_type type) void erase_duplicate_ns_defs (void *nd, std::deque< ns_list_type > &defs) void erase_duplicate_ns_defs_single_node (void *nd, std::deque< ns_list_type > &defs) void erase_unused_ns_defs (void *nd) ns_list_type get_namespace_definitions (void *nd, ns::ns_safety_type type) const void * find_replacement_ns_def (std::deque< ns_list_type > &defs, void *ns) void * create_xpath_context (const xml::xpath_expression &expr) const void * evaluate_xpath_expression (const xml::xpath_expression &expr, void *context) const friend void ::xslt_ext_func_cb (void *, int) friend void ::xslt_ext_element_cb (void *, void *, void *, void *)
The xml::node class is used to hold information about one XML node.
This includes the name of the node, the namespace of the node and attributes for the node. It also has an iterator whereby you can get to the children nodes.
It should be noted that any member function that returns a const char* returns a temporary value. The pointer that is returned will change with ANY operation to the xml::node. If you need the data to stick around a little longer you should put it inside a std::string.
Definition at line 106 of file node.hpp.
◆ size_type ◆ effective_ns_list_type
enum to specify what namespaces to include into the list of the node effective namespaces
Enumerator type_ns_all
include all namespaces
type_ns_only_default
include only default namespace
type_ns_only_non_default
include only non-default namespaces
Definition at line 155 of file node.hpp.
◆ node_type
enum for the different types of XML nodes
Enumerator type_element
XML element such as "<chapter/>".
type_text
Text node.
type_cdata
text
type_pi
Processing Instruction.
type_comment
XML comment.
type_entity
Entity as in &.
type_entity_ref
Entity ref.
type_xinclude
<xi:include/> node
type_document
Document node.
type_document_type
DOCTYPE node.
type_document_frag
Document Fragment.
type_notation
Notation.
type_dtd
DTD node.
type_dtd_element
DTD <!ELEMENT> node.
type_dtd_attribute
DTD <!ATTRLIST> node.
type_dtd_entity
DTD <!ENTITY>
type_dtd_namespace
?
Definition at line 112 of file node.hpp.
◆ ns_definition_adding_type
enum for policies of adding namespace definitions
Enumerator type_replace_if_exists
replace URI if ns with the same prefix exists
type_throw_if_exists
throw exception if ns with the same prefix exists
Definition at line 133 of file node.hpp.
◆ ns_definition_erase_type
enum to specify how to remove namespace definitions
Enumerator type_ns_def_erase_if_not_used
Remove the definition only if it is not in use.
If the definition is in use then throw an exception.
type_ns_def_erase_enforce
Remove the definition regardless if it is used or not.
If any attribute or node uses the definition then its namespace will be adjusted to a default one (if defined above) or will be set to no namespace (otherwise).
Definition at line 139 of file node.hpp.
◆ node() [1/10] ◆ node() [2/10] xml::node::node ( const char * name ) explicit ◆ node() [3/10] xml::node::node ( const char * name, const char * content )
Construct a new xml::node given a name and content.
The content will be used to create a new child text node. All the special symbols ('<', '>', '&', '"', '\r') in the given content are encoded before assigning the new content. If entities are needed in the content please use set_raw_content(...).
-
Parameters
-
name The name of the new element. content The text that will be used to create a child node.
-
Author
-
Peter Jones
Definition at line 424 of file node.cpp.
References pimpl_, and xml::impl::node_impl::xmlnode_.
◆ node() [4/10] xml::node::node ( cdata cdata_info ) explicit
Construct a new xml::node that is of type_cdata.
The cdata_info parameter should contain the contents of the CDATA section.
-
Note
-
Sample Use Example:
The xml::node class is used to hold information about one XML node.
Helper struct for creating a xml::node of type_cdata.
-
Parameters
-
cdata_info A cdata struct that tells xml::node what the content will be.
-
Author
-
Peter Jones
Definition at line 448 of file node.cpp.
References pimpl_, xml::node::cdata::t, and xml::impl::node_impl::xmlnode_.
◆ node() [5/10] xml::node::node ( comment comment_info ) explicit ◆ node() [6/10] xml::node::node ( pi pi_info ) explicit
Construct a new xml::node that is of type_pi.
The pi_info parameter should contain the name of the XML processing instruction (PI), and optionally, the contents of the XML PI.
-
Note
-
Sample Use Example:
Helper struct for creating a xml::node of type_pi.
-
Parameters
-
pi_info A pi struct that tells xml::node what the name and contents of the XML PI are.
-
Author
-
Peter Jones
Definition at line 473 of file node.cpp.
References xml::node::pi::c, xml::node::pi::n, pimpl_, and xml::impl::node_impl::xmlnode_.
◆ node() [7/10] xml::node::node ( text text_info ) explicit ◆ ~node() xml::node::~node ( void ) virtual
Class destructor.
-
Author
-
Peter Jones
Definition at line 740 of file node.cpp.
References NULL.
◆ node() [8/10] ◆ node() [9/10] xml::node::node ( node && other )
Moving constructor.
-
Parameters
-
Definition at line 532 of file node.cpp.
References NULL.
◆ node() [10/10] ◆ add_matched_namespace_def() ◆ add_namespace_def() ◆ add_namespace_definition()
Add namespace definition to the node.
If the node already has a namespace definition with the same prefix then its URI will be replaced with the new one, and that's it. Otherwise, the hierarchy of nodes (including their attributes) is walked down, updating all namespaces (with the same prefix) which do not use namespace definitions (with the same prefix) which are redefined below this node.
-
Parameters
-
name_space The namespace definition to add to the node. type What to do (replace or throw exception) when encountering a namespace definition with the same prefix.
-
Returns
-
Unsafe namespace
Definition at line 945 of file node.cpp.
References xml::ns::get_prefix(), xml::ns::get_uri(), xml::ns::is_void(), and NULL.
◆ add_namespace_definitions()
Add namespace definitions to the node.
-
See also
-
add_namespace_definition
-
Parameters
-
name_spaces List of namespace definitions to add to the node. type What to do (replace or throw exception) when encountering a namespace definition with the same prefix.
Definition at line 982 of file node.cpp.
References first(), and last().
◆ append_to_string()
Convert the node and all its children into XML text and set the given string to that text.
-
Parameters
-
xml The string to set the node's XML data to (the string is not cleared; the content is appended to the string). flags Bitwise 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.
Definition at line 1568 of file node.cpp.
References xml::impl::convert_to_libxml2_save_options(), flags, NULL, and xml::impl::save_to_string_cb().
◆ assign()
Copy another node object into this one.
This node object will be an exact copy of the other node after the assignement.
-
Parameters
-
other The node to copy from.
-
Returns
-
*this
-
Author
-
Denis Vakatov
Definition at line 507 of file node.cpp.
References swap().
Referenced by CXmlNodeObject::CXmlNodeObject().
◆ begin() [1/2] ◆ begin() [2/2]
Get a const_iterator that points to the beginning of this node's children.
-
Returns
-
A const_iterator that points to the beginning of the children.
-
Author
-
Peter Jones
Definition at line 1222 of file node.cpp.
◆ clear() void xml::node::clear ( void )
Erase all children nodes.
-
Author
-
tbrowder2
Definition at line 1511 of file node.cpp.
References NULL.
◆ convert_to_nset() node_set xml::node::convert_to_nset ( void * object_as_void ) const private ◆ create_xpath_context() ◆ detached_copy() xml::node * xml::node::detached_copy ( void ) const
Create a copy of the node which is detached from the document.
The nested nodes as well as namespace definitions are copied too.
-
Returns
-
A pointer to the copied node. The user is responsible to delete it.
-
Exceptions
-
Definition at line 521 of file node.cpp.
◆ empty() bool xml::node::empty ( void ) const
Find out if this node has any children.
This is the same as xml::node::size() == 0 except it is much faster.
-
Returns
-
True if this node DOES NOT have any children.
-
False if this node does have children.
-
Author
-
Peter Jones
Definition at line 1212 of file node.cpp.
◆ end() [1/2]
Get an iterator that points one past the last child for this node.
-
Returns
-
A "one past the end" iterator.
-
Author
-
Peter Jones
Definition at line 835 of file node.hpp.
Referenced by AddStructuredCommentToAttributes(), CNADocSumIterator::CNADocSumIterator(), GetBiosampleStatus(), CDocsumTableModel::GetExtraValueAt(), CXmlNodeObjectLabelHandler::GetLabel(), CSeqUtils::GetXmlChildNodeValue(), CNADocSumIterator::is_valid(), CAssemblyInfo::IsSameAssembly(), ProcessBiosampleStatusNode(), ProcessBulkBioSample(), s_GetTitle(), s_GetValFromChildren(), CEntrezSearchJob::SetReleaseType(), CGBankLoadingJob::x_Convert(), CNAUtils::x_GetAllGIs(), and CAssemblyInfo::x_GetAssmInfo().
◆ end() [2/2] ◆ erase() [1/3]
Erase all children nodes with the given name.
This will find all nodes that have the given node name and remove them from this node. This will invalidate any iterators that point to the nodes to be erased, or any pointers or references to those nodes.
-
Parameters
-
name The name of nodes to remove.
-
Returns
-
The number of nodes removed.
-
Author
-
Peter Jones
Definition at line 1498 of file node.cpp.
◆ erase() [2/3]
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.
-
Parameters
-
to_erase An iterator that points to the node to be erased.
-
Returns
-
An iterator that points to the node after the one being erased.
-
Author
-
Peter Jones
-
Gary A. Passero
Definition at line 1486 of file node.cpp.
References xml::node::iterator::get_raw_node(), and xml::impl::node_erase().
◆ erase() [3/3]
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.
-
Parameters
-
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().
-
Returns
-
An iterator that points to the node after the last one being erased.
-
Author
-
Peter Jones
Definition at line 1492 of file node.cpp.
References first(), and last().
◆ erase_duplicate_ns_defs() [1/2] void xml::node::erase_duplicate_ns_defs ( void * nd, std::deque< ns_list_type > & defs ) private ◆ erase_duplicate_ns_defs() [2/2] void xml::node::erase_duplicate_ns_defs ( void )
Erase duplicate namespace definitions.
Walks the nodes hierarchy down and erases dulicate namespace definitions.
Definition at line 1084 of file node.cpp.
References xml::ns::type_unsafe_ns.
◆ erase_duplicate_ns_defs_single_node() void xml::node::erase_duplicate_ns_defs_single_node ( void * nd, std::deque< ns_list_type > & defs ) private ◆ erase_namespace() void xml::node::erase_namespace ( void )
Remove the node namespace.
The hierarchy of nodes is searched up and if a default namespace is found then it is used as a new node namespace.
Definition at line 1077 of file node.cpp.
References NULL.
◆ erase_namespace_definition() ◆ erase_unused_ns_defs() [1/2] void xml::node::erase_unused_ns_defs ( void * nd ) private ◆ erase_unused_ns_defs() [2/2] void xml::node::erase_unused_ns_defs ( void )
Erase unused namespace definitions.
Walks the nodes hierarchy down and erases unused namespace definitions.
Definition at line 1151 of file node.cpp.
◆ evaluate_xpath_expression() ◆ find() [1/4]
Find the first child node, starting with the given const_iterator, that has the given name and namespace.
If no such node can be found, this function will return the same const_iterator that end() would return.
This function should be given a const_iterator to one of this node's children. The search will begin with that node and continue with all its siblings. This function will not recurse down the tree, it only searches in one level.
-
Parameters
-
name The name of the node you want to find. start Where to begin the search. nspace The namespace of the node to find. NULL matches any namespace. Void namespace matches node without namespace set.
-
Returns
-
A const_iterator that points to the node if found.
-
An end() const_iterator if the node was not found.
-
Author
-
Peter Jones
-
See also
-
elements(const char*) const
Definition at line 1283 of file node.cpp.
References xml::node::const_iterator::get_raw_node(), and n.
◆ find() [2/4]
Find the first child node, starting with the given iterator, that has the given name and namespace.
If no such node can be found, this function will return the same iterator that end() would return.
This function should be given an iterator to one of this node's children. The search will begin with that node and continue with all its sibliings. This function will not recurse down the tree, it only searches in one level.
-
Parameters
-
name The name of the node you want to find. start Where to begin the search. nspace The namespace of the node to find. NULL matches any namespace. Void namespace matches node without namespace set.
-
Returns
-
An iterator that points to the node if found.
-
An end() iterator if the node was not found.
-
Author
-
Peter Jones
-
See also
-
elements(const char*)
Definition at line 1274 of file node.cpp.
References xml::node::iterator::get_raw_node(), and n.
◆ find() [3/4]
Find the first child node that has the given name and namespace.
If no such node can be found, this function will return the same iterator that end() would return.
This function is not recursive. That is, it will not search down the tree for the requested node. Instead, it will only search one level deep, only checking the children of this node.
-
Parameters
-
name The name of the node you want to find. nspace The namespace of the node to find. NULL matches any namespace. Void namespace matches node without namespace set.
-
Returns
-
An iterator that points to the node if found.
-
An end() iterator if the node was not found.
-
Author
-
Peter Jones
-
See also
-
elements(const char*), find(const char*, iterator)
Definition at line 1258 of file node.cpp.
Referenced by CNADocSumIterator::CNADocSumIterator(), CDocsumTableModel::GetExtraValueAt(), CXmlNodeObjectLabelHandler::GetLabel(), CSeqUtils::GetXmlChildNodeValue(), CAssemblyInfo::IsSameAssembly(), CEntrezSearchJob::SetReleaseType(), CGBankLoadingJob::x_Convert(), CAssemblyInfo::x_GetAssmInfo(), and CNAUtils::x_GetNAEntrezLinks().
◆ find() [4/4]
Find the first child node that has the given name and namespace.
If no such node can be found, this function will return the same const_iterator that end() would return.
This function is not recursive. That is, it will not search down the tree for the requested node. Instead, it will only search one level deep, only checking the children of this node.
-
Parameters
-
name The name of the node you want to find. nspace The namespace of the node to find. NULL matches any namespace. Void namespace matches node without namespace set.
-
Returns
-
A const_iterator that points to the node if found.
-
An end() const_iterator if the node was not found.
-
Author
-
Peter Jones
-
See also
-
elements(const char*) const, find(const char*, const_iterator) const
Definition at line 1266 of file node.cpp.
◆ find_attribute() [1/2]
Search for a node attribute.
-
Parameters
-
name The name of the attribute to find. The name could be given as a qualified name, e.g. 'prefix:attr_name'. If the name is qualified then the nspace argument must be NULL (otherwise an exception is generated) and the attribute search is namespace aware with an effective namespace identified by the given prefix. nspace The namespace of the atrribute to find:
- NULL matches any namespace
- Void namespace matches attributes without a namespace set
- Unsafe namespace is used as it is
- A safe namespace is resolved basing on the uri only
-
Returns
-
iterator to the found attribute. If there is no such an attribute then the provided iterator equals to attributes::end().
Definition at line 851 of file node.cpp.
Referenced by CEntrezDB::GetUidAttr().
◆ find_attribute() [2/2]
Search for a node attribute.
-
Parameters
-
name The name of the attribute to find. The name could be given as a qualified name, e.g. 'prefix:attr_name'. If the name is qualified then the nspace argument must be NULL (otherwise an exception is generated) and the attribute search is namespace aware with an effective namespace identified by the given prefix. nspace The namespace of the atrribute to find:
- NULL matches any namespace
- Void namespace matches attributes without a namespace set
- Unsafe namespace is used as it is
- A safe namespace is resolved basing on the uri only
-
Returns
-
const iterator to the found attribute. If there is no such an attribute then the provided iterator equals to attributes::end().
Definition at line 858 of file node.cpp.
◆ find_replacement_ns_def() void * xml::node::find_replacement_ns_def ( std::deque< ns_list_type > & defs, void * ns ) private ◆ get_attributes() [1/2]
Get the list of attributes.
You can use the returned object to get and set the attributes for this node. Make sure you use a reference to this returned object, to prevent a copy.
-
Returns
-
The xml::attributes object for this node.
-
Author
-
Peter Jones
Definition at line 831 of file node.cpp.
Referenced by CTabDelimitedValidator::_ReportXML(), AddContact(), AddStructuredCommentToAttributes(), convert_to_nset(), GetBioSampleStatusFromNode(), CEntrezDB::GetUidAttr(), PrintBioseqXML(), ProcessBiosampleStatusNode(), CFormatGuessApp::Run(), s_AddSamplePair(), CGapStatsApplication::x_PrintHistogram(), CGapStatsApplication::x_PrintSeqsForGapLengths(), and CGapStatsApplication::x_PrintSummaryView().
◆ get_attributes() [2/2]
Get the list of attributes.
You can use the returned object to get the attributes for this node. Make sure you use a reference to this returned object, to prevent a copy.
-
Returns
-
The xml::attributes object for this node.
-
Author
-
Peter Jones
Definition at line 841 of file node.cpp.
◆ get_content() const char * xml::node::get_content ( void ) const
Get the content for this text node.
If this node is not a text node but it has children nodes that are text nodes, the contents of those child nodes will be returned. If there is no content or these conditions do not apply, zero will be returned.
This function may change in the future to return std::string. Feedback is welcome.
-
Returns
-
The content or 0.
-
Author
-
Peter Jones
Definition at line 797 of file node.cpp.
References xml::impl::xmlchar_helper::get().
Referenced by BOOST_AUTO_TEST_CASE(), CSeqUtils::GetAssmAccs_Gi(), CSeqUtils::GetAssmIds_GIChr(), CDocsumTableModel::GetExtraValueAt(), CXmlNodeObjectLabelHandler::GetLabel(), CSeqUtils::GetXmlChildNodeValue(), CAssemblyInfo::IsSameAssembly(), s_ELinkQuery(), s_ESearchQuery(), s_GetTitle(), s_GetValFromChildren(), CEntrezSearchJob::SetReleaseType(), CGBankLoadingJob::x_Convert(), CNAUtils::x_GetAllGIs(), CNAUtils::x_GetAllNAIdsWithContext(), CAssemblyInfo::x_GetAssmInfo(), CNAUtils::x_GetNAAs(), CNAUtils::x_GetNAEntrezLinks(), and CNAUtils::x_GetNAMetaData().
◆ get_effective_namespaces()
Provides a list of effective namespaces for the node.
-
Parameters
-
which Specifies what namespaces should be included into the list.
Definition at line 1354 of file node.cpp.
References NULL.
◆ get_name() const char * xml::node::get_name ( void ) const ◆ get_namespace() ◆ get_namespace_definitions() [1/2]
Get the namespaces defined at this xml::node.
-
Parameters
-
type The required type of namespace objects (safe/unsafe).
-
Returns
-
The namespaces defined at this node. If no namespaces are defined then return an empty container.
Definition at line 876 of file node.cpp.
◆ get_namespace_definitions() [2/2] ◆ get_node_data() void * xml::node::get_node_data ( void ) const private ◆ get_path()
Get the node path.
-
Returns
-
node path
-
Exceptions
-
throw an exception in case of errors
Definition at line 1178 of file node.cpp.
References string.
◆ get_type() ◆ insert() [1/2]
Insert a new child node.
The new node will be inserted before the node pointed to by the given iterator.
-
Parameters
-
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 node.
-
Returns
-
An iterator that points to the newly inserted node.
-
Author
-
Peter Jones
Definition at line 1469 of file node.cpp.
References xml::node::iterator::get_raw_node(), n, and xml::impl::node_insert().
◆ insert() [2/2] ◆ is_root() bool xml::node::is_root ( void ) const
Find out if this node is a root one, i.e.
has no parent.
-
Returns
-
true if the node is root.
Definition at line 1237 of file node.cpp.
References NULL.
◆ is_text() bool xml::node::is_text ( void ) const
Find out if this node is a text node or sometiming like a text node, CDATA for example.
-
Returns
-
True if this node is a text node; false otherwise.
-
Author
-
Peter Jones
Definition at line 1189 of file node.cpp.
Referenced by s_GetTitle(), and CNAUtils::x_GetAllGIs().
◆ lookup_namespace()
Look up a namespace with the given prefix.
Walk the nodes hierarchy up and check the namespace definition prefixes. If the prefix matches, then return the corresponding safe/unsafe namespace object.
-
Parameters
-
prefix Namespace prefix to look for. For the default namespace use NULL or empty string. type Type of namespace object (safe/unsafe) to return.
-
Returns
-
Namespace object ("void" namespace if none found).
Definition at line 1025 of file node.cpp.
References NULL, xml::ns::type_safe_ns, and xml::ns::type_void.
◆ operator=() [1/2]
Make this node equal to some other node via assignment.
-
Parameters
-
other The other node to copy.
-
Returns
-
A reference to this node.
-
Author
-
Peter Jones
Definition at line 514 of file node.cpp.
References swap().
◆ operator=() [2/2] ◆ parent() [1/2]
Get an iterator that points at the parent of this node.
If this node does not have a parent, this member function will return an "end" iterator.
-
Note
-
It is recommended to call is_root() function before calling parent(). If is_root() returns true then the parent() provided iterator cannot be dereferenced.
-
Returns
-
An iterator that points to this nodes parent.
-
If no parent, returns the same iterator that xml::node::end() returns.
-
Author
-
Peter Jones
Definition at line 1244 of file node.cpp.
Referenced by xml::impl::lookup_default_ns_above().
◆ parent() [2/2] ◆ push_back() void xml::node::push_back ( const node & child ) ◆ release_node_data() void * xml::node::release_node_data ( void ) private ◆ replace()
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.
-
Parameters
-
old_node An iterator that points to the node that should be removed. new_node The node to put in old_node's place.
-
Returns
-
An iterator that points to the new node.
-
Author
-
Peter Jones
Definition at line 1479 of file node.cpp.
References xml::node::iterator::get_raw_node(), xml::impl::node_replace(), pimpl_, and xml::impl::node_impl::xmlnode_.
◆ run_xpath_query() [1/4]
Run the given XPath query.
The method collects all the effective namespace definitions for the node and register them automatically before running the query.
-
Parameters
-
expr XPath expression to run, must not be NULL
-
Returns
-
XPath query result nodes set
-
Attention
-
Expressions like "root/node" will result in 0 matches even if the document has <root><node></root>, due to a bug in libxml2 (at least till version 2.9.1). The workaround is to use "/root/node" or "//root/node" depending on circumstances.
-
XPath query cannot match nodes that belong specifically to the default namespace. Please see a detailed discussion (and solution) on that in the C++ Toolkit book: http://ncbi.github.io/cxx-toolkit/pages/ch_xmlwrapp#ch_xmlwrapp.Run_an_XPath_Query_with_a_De
-
Exceptions
-
Throws exceptions in case of problems
-
Note
-
Default namespace, if so, will not be registered
-
If the query result is a scalar value (e.g. count() function) then the result set will have a single node of the following format: <xpath_scalar_result type="TYPE">VALUE</xpath_scalar_result> where TYPE is one of the following: boolean, number, or string depending on the result type. The VALUE is the actual result scalar value.
Definition at line 1341 of file node.cpp.
◆ run_xpath_query() [2/4]
Run the given XPath query.
The method collects all the effective namespace definitions for the node and register them automatically before running the query.
-
Parameters
-
expr XPath expression to run, must not be NULL
-
Returns
-
XPath query const result nodes set
-
Attention
-
Expressions like "root/node" will result in 0 matches even if the document has <root><node></root>, due to a bug in libxml2 (at least till version 2.9.1). The workaround is to use "/root/node" or "//root/node" depending on circumstances.
-
XPath query cannot match nodes that belong specifically to the default namespace. Please see a detailed discussion (and solution) on that in the C++ Toolkit book: http://ncbi.github.io/cxx-toolkit/pages/ch_xmlwrapp#ch_xmlwrapp.Run_an_XPath_Query_with_a_De
-
Exceptions
-
Throws exceptions in case of problems
-
Note
-
Default namespace, if so, will not be registered
-
If the query result is a scalar value (e.g. count() function) then the result set will have a single node of the following format: <xpath_scalar_result type="TYPE">VALUE</xpath_scalar_result> where TYPE is one of the following: boolean, number, or string depending on the result type. The VALUE is the actual result scalar value.
Definition at line 1347 of file node.cpp.
◆ run_xpath_query() [3/4]
Run the given XPath query.
-
Parameters
-
expr XPath expression to run
-
Returns
-
XPath query result node set
-
Attention
-
The result node set is essentially a list of references to an XML document. Thus the life time of the document must be wider than the node set life time. It also means that the document modifications after a result node set is received must be done carefully, e.g. node removal. The removed node may be referenced in the node set and access to it can cause problems.
-
Expressions like "root/node" will result in 0 matches even if the document has <root><node></root>, due to a bug in libxml2 (at least till version 2.9.1). The workaround is to use "/root/node" or "//root/node" depending on circumstances.
-
XPath query cannot match nodes that belong specifically to the default namespace. Please see a detailed discussion (and solution) on that in the C++ Toolkit book: http://ncbi.github.io/cxx-toolkit/pages/ch_xmlwrapp#ch_xmlwrapp.Run_an_XPath_Query_with_a_De
-
Note
-
If the query result is a scalar value (e.g. count() function) then the result set will have a single node of the following format: <xpath_scalar_result type="TYPE">VALUE</xpath_scalar_result> where TYPE is one of the following: boolean, number, or string depending on the result type. The VALUE is the actual result scalar value.
Definition at line 1292 of file node.cpp.
References evaluate_xpath_expression().
Referenced by BOOST_AUTO_TEST_CASE(), CSeqUtils::GetAssmAccs_Gi(), CSeqUtils::GetAssmIds_GIChr(), CRfamTool::GetModelByAccession(), CRfamTool::GetModelByIdentification(), CAssemblyInfo::IsSameAssembly(), s_ELinkQuery(), s_ESearchQuery(), CEntrezSearchJob::x_DoSearch(), CNAUtils::x_GetAllNAIdsWithContext(), CAssemblyInfo::x_GetAssmInfo(), and CNAUtils::x_GetNAEntrezLinks().
◆ run_xpath_query() [4/4]
Run the given XPath query.
-
Parameters
-
expr XPath expression to run
-
Returns
-
XPath query const result node set
-
Attention
-
The result node set is essentially a list of references to an XML document. Thus the life time of the document must be wider than the node set life time. It also means that the document modifications after a result node set is received must be done carefully, e.g. node removal. The removed node may be referenced in the node set and access to it can cause problems.
-
Expressions like "root/node" will result in 0 matches even if the document has <root><node></root>, due to a bug in libxml2 (at least till version 2.9.1). The workaround is to use "/root/node" or "//root/node" depending on circumstances.
-
XPath query cannot match nodes that belong specifically to the default namespace. Please see a detailed discussion (and solution) on that in the C++ Toolkit book: http://ncbi.github.io/cxx-toolkit/pages/ch_xmlwrapp#ch_xmlwrapp.Run_an_XPath_Query_with_a_De
-
Note
-
If the query result is a scalar value (e.g. count() function) then the result set will have a single node of the following format: <xpath_scalar_result type="TYPE">VALUE</xpath_scalar_result> where TYPE is one of the following: boolean, number, or string depending on the result type. The VALUE is the actual result scalar value.
Definition at line 1316 of file node.cpp.
References evaluate_xpath_expression().
◆ save_to_string()
Convert the node and all its children into XML text and set the given string to that text.
-
Parameters
-
xml The string to set the node's XML data to. The string is cleared. flags Bitwise 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.
Definition at line 1594 of file node.cpp.
References flags.
Referenced by print_xml_node().
◆ save_to_string_canonical() ◆ self() [1/2]
Get an iterator that points back at this node.
-
Returns
-
An iterator that points at this node.
-
Author
-
Peter Jones
Definition at line 1227 of file node.cpp.
◆ self() [2/2] ◆ set_content() void xml::node::set_content ( const char * content )
Set the content of a node.
If this node is an element node, this function will remove all of its children nodes and replace them with one text node set to the new content. All the special symbols ('<', '>', '&', '"', '\r') in the given content are encoded before assigning the new content. If entities are needed in the content please use set_raw_content(...).
-
Parameters
-
content The content of the text node.
-
Author
-
Peter Jones
Definition at line 774 of file node.cpp.
References NULL.
◆ set_name() void xml::node::set_name ( const char * name )
Set the name of this xml::node.
-
Parameters
-
-
Author
-
Peter Jones
Definition at line 764 of file node.cpp.
◆ set_namespace() [1/2]
Set the node namespace.
The namespace definition is searched up in the hierarchy of nodes. If a namespace with the given prefix is not found then throw an exception.
-
Parameters
-
prefix Namespace prefix. For the default namespace use NULL or empty string.
-
Returns
-
Unsafe namespace
Definition at line 903 of file node.cpp.
References NULL.
◆ set_namespace() [2/2] ◆ set_node_data() void xml::node::set_node_data ( void * data ) private ◆ set_raw_content() void xml::node::set_raw_content ( const char * raw_content )
Set the raw content of a node.
If this node is an element node, this function will remove all of its children nodes and replace them with one text node set to the new content. The given content is checked for '<' and '>' characters. If found they will be replaced with '<' and '>' respectively and this is the only potential conversion done for the given raw content. This member is likely used if entities are needed in the node content. In any case it is the user responsibility to provide valid content for this member.
-
Parameters
-
raw_content The raw content of the text node.
Definition at line 791 of file node.cpp.
◆ size() ◆ sort() [1/2] void xml::node::sort ( const char * node_name, const char * attr_name )
Sort all the children nodes of this node using one of thier attributes.
Only nodes that are of xml::node::type_element will be sorted, and they must have the given node_name.
The sorting is done by calling std::strcmp on the value of the given attribute.
-
Parameters
-
node_name The name of the nodes to sort. attr_name The attribute to sort on.
-
Author
-
Peter Jones
Definition at line 1520 of file node.cpp.
References i, next(), and ct::sort().
◆ sort() [2/2]
template<typename T >
void xml::node::sort ( T compare ) inline
Sort all the children nodes of this node using the given comparison function object.
All element type nodes will be considered for sorting.
-
Parameters
-
compare The binary function object to call in order to sort all child nodes.
-
Author
-
Peter Jones
Definition at line 1266 of file node.hpp.
References sort_fo().
◆ sort_fo() ◆ sort_namespace_definitions() void xml::node::sort_namespace_definitions ( void )
Sorts the namespace definitions in the node in place.
Definition at line 1696 of file node.cpp.
References NULL, and prev().
◆ swap() void xml::node::swap ( node & other ) ◆ void ::xslt_ext_element_cb() ◆ void ::xslt_ext_func_cb() ◆ document ◆ impl::attach_node_private_data ◆ impl::doc_impl ◆ impl::node_cmp ◆ impl::node_iterator ◆ operator<< std::ostream& operator<< ( std::ostream & stream, const node & n ) friend
Write a node and all of its children to the given stream.
-
Parameters
-
stream The stream to write the node as XML. n The node to write to the stream.
-
Returns
-
The stream.
-
Author
-
Peter Jones
Definition at line 1733 of file node.cpp.
◆ xslt::extension_element ◆ xslt::xpath_object ◆ pimpl_
The documentation for this class was generated from the following files:
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4