46 #ifndef _xmlwrapp_node_h_
47 #define _xmlwrapp_node_h_
74 class extension_element;
81 class xpath_expression;
86 class iter_advance_functor;
91 struct node_private_data;
193 explicit pi (
const char *name,
const char *content=0) :
n(name),
c(content) { }
205 explicit text (
const char *txt) :
t(txt) { }
226 explicit node (
const char *name);
241 node (
const char *name,
const char *content);
290 explicit node (
pi pi_info);
339 virtual ~node (
void);
492 const ns* nspace =
NULL)
const;
729 {
return !(*
this == other); }
772 {
return !(*
this == other); }
804 bool empty (
void)
const;
856 iterator
self (void);
866 const_iterator
self (void)
const;
911 const_iterator
parent (
void)
const;
934 iterator
find (
const char *name,
const ns *nspace=
NULL);
957 const_iterator
find (
const char *name,
const ns *nspace=
NULL)
const;
982 iterator
find (
const char *name,
const iterator& start,
const ns *nspace=
NULL);
1008 const_iterator
find (
const char *name,
const const_iterator& start,
1009 const ns *nspace=
NULL)
const;
1170 iterator
insert (
const iterator& position,
const node &
n);
1186 iterator
replace (
const iterator& old_node,
const node &new_node);
1201 iterator
erase (
const iterator& to_erase);
1254 void sort (
const char *node_name,
const char *attr_name);
1266 template <
typename T>
void sort (
T compare)
1349 friend std::ostream&
operator<< (std::ostream &stream,
const node &
n);
1388 explicit node (
int);
This file contains the definition of the xml::attributes class.
Const Iterator class for accessing attribute pairs.
Iterator class for accessing attribute pairs.
The xml::attributes class is used to access all the attributes of one xml::node.
The xml::document class is used to hold the XML tree and various bits of information about it.
The xml::node::const_iterator provides a way to access children nodes similar to a standard C++ conta...
const_iterator & operator++(void)
prefix increment
void swap(const_iterator &other)
void * get_raw_node(void) const
reference operator*(void) const
std::ptrdiff_t difference_type
const_iterator & operator=(const const_iterator &other)
std::forward_iterator_tag iterator_category
bool operator!=(const const_iterator &other) const
pointer operator->(void) const
bool operator==(const const_iterator &other) const
The xml::node::iterator provides a way to access children nodes similar to a standard C++ container.
iterator & operator++(void)
prefix increment
std::forward_iterator_tag iterator_category
pointer operator->(void) const
iterator & operator=(const iterator &other)
void * get_raw_node(void) const
std::ptrdiff_t difference_type
bool operator==(const iterator &other) const
void swap(iterator &other)
reference operator*(void) const
bool operator!=(const iterator &other) const
The xml::node_set class is used to store xpath query result set.
The xml::node class is used to hold information about one XML node.
void set_name(const char *name)
Set the name of this xml::node.
node_set convert_to_nset(void *) const
node_type get_type(void) const
Get this node's "type".
void * release_node_data(void)
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.
ns_definition_adding_type
enum for policies of adding namespace definitions
@ 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
void sort(T compare)
Sort all the children nodes of this node using the given comparison function object.
void erase_namespace(void)
Remove the node namespace.
attributes::iterator find_attribute(const char *name, const ns *nspace=NULL)
Search for a node attribute.
bool is_text(void) const
Find out if this node is a text node or sometiming like a text node, CDATA for example.
friend std::ostream & operator<<(std::ostream &stream, const node &n)
Write a node and all of its children to the given stream.
const char * get_name(void) const
Get the name of this xml::node.
ns_list_type get_namespace_definitions(ns::ns_safety_type type=ns::type_safe_ns) const
Get the namespaces defined at this xml::node.
effective_ns_list_type
enum to specify what namespaces to include into the list of the node effective namespaces
@ type_ns_only_default
include only default namespace
@ type_ns_all
include all namespaces
@ type_ns_only_non_default
include only non-default namespaces
iterator erase(const iterator &to_erase)
Erase the node that is pointed to by the given iterator.
void * evaluate_xpath_expression(const xml::xpath_expression &expr, void *context) const
ns add_namespace_definition(const ns &name_space, ns_definition_adding_type type)
Add namespace definition to the node.
void clear(void)
Erase all children nodes.
iterator parent(void)
Get an iterator that points at the parent of this node.
void erase_unused_ns_defs(void)
Erase unused namespace definitions.
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.
void set_node_data(void *data)
iterator end(void)
Get an iterator that points one past the last child for this node.
node & assign(const node &other)
Copy another node object into this one.
ns set_namespace(const ns &name_space)
Set the node namespace.
ns_definition_erase_type
enum to specify how to remove namespace definitions
@ type_ns_def_erase_if_not_used
Remove the definition only if it is not in use.
@ type_ns_def_erase_enforce
Remove the definition regardless if it is used or not.
ns_list_type get_effective_namespaces(effective_ns_list_type which=type_ns_all) const
Provides a list of effective namespaces for the node.
node(void)
Construct a new blank xml::node.
bool empty(void) const
Find out if this node has any children.
void push_back(const node &child)
Add a child xml::node to this node.
iterator find(const char *name, const ns *nspace=NULL)
Find the first child node that has the given name and namespace.
void erase_duplicate_ns_defs(void)
Erase duplicate namespace definitions.
void * get_node_data(void) const
void erase_duplicate_ns_defs_single_node(void *nd, std::deque< ns_list_type > &defs)
void * create_xpath_context(const xml::xpath_expression &expr) const
node_type
enum for the different types of XML nodes
@ type_element
XML element such as "<chapter/>".
@ type_xinclude
<xi:include/> node
@ type_document_frag
Document Fragment.
@ type_document_type
DOCTYPE node.
@ type_dtd_element
DTD <!ELEMENT> node.
@ type_document
Document node.
@ type_comment
XML comment.
@ type_dtd_entity
DTD <!ENTITY>
@ type_entity
Entity as in &.
@ type_entity_ref
Entity ref.
@ type_pi
Processing Instruction.
@ type_dtd_attribute
DTD <!ATTRLIST> node.
iterator replace(const iterator &old_node, const node &new_node)
Replace the node pointed to by the given iterator with another node.
iterator begin(void)
Get an iterator that points to the beginning of this node's children.
ns add_namespace_def(const char *uri, const char *prefix)
node * detached_copy(void) const
Create a copy of the node which is detached from the document.
std::string get_path(void) const
Get the node path.
virtual ~node(void)
Class destructor.
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.
void set_content(const char *content)
Set the content of a node.
ns get_namespace(ns::ns_safety_type type=ns::type_safe_ns) const
Get the namespace of this xml::node.
node_set run_xpath_query(const xpath_expression &expr)
Run the given XPath query.
void * find_replacement_ns_def(std::deque< ns_list_type > &defs, void *ns)
void sort_namespace_definitions(void)
Sorts the namespace definitions in the node in place.
const_iterator end(void) const
Get a const_iterator that points one past the last child for this node.
node & operator=(const node &other)
Make this node equal to some other node via assignment.
const char * get_content(void) const
Get the content for this text node.
void erase_namespace_definition(const char *prefix, ns_definition_erase_type how=type_ns_def_erase_if_not_used)
Remove the node namespace definition.
std::size_t size_type
size type
bool is_root(void) const
Find out if this node is a root one, i.e.
void set_raw_content(const char *raw_content)
Set the raw content of a node.
void add_namespace_definitions(const ns_list_type &name_spaces, ns_definition_adding_type type)
Add namespace definitions to the node.
ns lookup_namespace(const char *prefix, ns::ns_safety_type type=ns::type_safe_ns) const
Look up a namespace with the given prefix.
void swap(node &other)
Swap this node with another one.
iterator insert(const node &n)
Insert a new child node.
size_type size(void) const
Returns the number of childer this nodes has.
void sort_fo(impl::cbfo_node_compare &fo)
ns add_matched_namespace_def(void *libxml2RawNamespace, const char *uri, ns_definition_adding_type type)
void sort(const char *node_name, const char *attr_name)
Sort all the children nodes of this node using one of thier attributes.
xml::attributes & get_attributes(void)
Get the list of attributes.
The xml::ns class is used to access and handle namespaces of nodes and attributes.
ns_safety_type
Namespace object "safety".
The xml::xpath_expression class is used to store xpath query string and optional XML namespaces.
The XSLT extension element object is used to be a base class for the user provided XSLT extension ele...
The xslt::xpath_object class is used to store extension function arguments and return values.
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
static const char * str(char *buf, int n)
XML namespace API for XmlWrapp.
void xslt_ext_func_cb(void *, int)
void xslt_ext_element_cb(void *, void *, void *, void *)
node_private_data * attach_node_private_data(void *)
int save_option_flags
Bitwise save options mask type and a compression level.
std::vector< xml::ns > ns_list_type
type for holding XML namespaces
canonicalization_comments_option
@ save_op_default
Default is:
canonicalization_option
Canonicalization mode.
canonicalization_format_option
canonicalization_node_sort_option
Front end for a platform-specific configuration summary.
Helper struct for creating a xml::node of type_cdata.
Helper struct for creating a xml::node of type_pi.
pi(const char *name, const char *content=0)
Helper struct for creating a xml::node of type_text.
static CS_CONTEXT * context
This file contains the definition of the xml::init class.
Flags for saving XML documents and nodes.