xmlnode.cc File Reference

handling of XML documents in a DOM like way More...

#include <jabberdlib.h>
#include <map>
#include <list>
#include <sstream>
#include <stdexcept>

Namespaces

namespace  xmppd

Functions

xmlnode xmlnode_new_tag (const char *name)
xmlnode xmlnode_new_tag_ns (const char *name, const char *prefix, const char *ns_iri)
xmlnode xmlnode_new_tag_pool (pool p, const char *name)
xmlnode xmlnode_new_tag_pool_ns (pool p, const char *name, const char *prefix, const char *ns_iri)
xmlnode xmlnode_insert_tag (xmlnode parent, const char *name)
xmlnode xmlnode_insert_tag_ns (xmlnode parent, const char *name, const char *prefix, const char *ns_iri)
xmlnode xmlnode_insert_cdata (xmlnode parent, const char *CDATA, unsigned int size)
xmlnode xmlnode_get_tag (xmlnode parent, const char *name)
xmlnode_vector xmlnode_get_tags (xmlnode context_node, const char *_path, xht namespaces)
char * xmlnode_get_tag_data (xmlnode parent, const char *name)
char * xmlnode_get_list_item_data (const xmlnode_vector &first, unsigned int i)
void xmlnode_change_namespace (xmlnode node, const char *ns_iri)
void xmlnode_put_attrib (xmlnode owner, const char *name, const char *value)
void xmlnode_put_attrib_ns (xmlnode owner, const char *name, const char *prefix, const char *ns_iri, const char *value)
char * xmlnode_get_attrib (xmlnode owner, const char *name)
char * xmlnode_get_attrib_ns (xmlnode owner, const char *name, const char *ns_iri)
xmlnode xmlnode_get_firstattrib (xmlnode parent)
xmlnode xmlnode_get_firstchild (xmlnode parent)
xmlnode xmlnode_get_lastchild (xmlnode parent)
xmlnode xmlnode_get_nextsibling (xmlnode sibling)
xmlnode xmlnode_get_prevsibling (xmlnode sibling)
xmlnode xmlnode_get_parent (xmlnode node)
char * xmlnode_get_name (xmlnode node)
const char * xmlnode_get_localname (xmlnode node)
const char * xmlnode_get_namespace (xmlnode node)
const char * xmlnode_get_nsprefix (xmlnode node)
char * xmlnode_get_data (xmlnode node)
int xmlnode_get_type (xmlnode node)
int xmlnode_has_children (xmlnode node)
pool xmlnode_pool (xmlnode node)
void xmlnode_hide (xmlnode child)
void xmlnode_hide_attrib (xmlnode parent, const char *name)
void xmlnode_hide_attrib_ns (xmlnode parent, const char *name, const char *ns_iri)
char * xmlnode_serialize_string (xmlnode_t const *node, const xmppd::ns_decl_list &nslist, int stream_type)
xmlnode xmlnode_insert_tag_node (xmlnode parent, xmlnode node)
void xmlnode_insert_node (xmlnode parent, xmlnode node)
xmlnode xmlnode_dup (xmlnode x)
xmlnode xmlnode_dup_pool (pool p, xmlnode x)
xmlnode xmlnode_wrap (xmlnode x, const char *wrapper)
xmlnode xmlnode_wrap_ns (xmlnode x, const char *name, const char *prefix, const char *ns_iri)
void xmlnode_free (xmlnode node)
const char * xmlnode_get_lang (xmlnode node)
xmlnode xmlnode_get_list_item (const xmlnode_vector &first, unsigned int i)
xmlnode xmlnode_select_by_lang (const xmlnode_vector &nodes, const char *lang)
void xmlnode_stat ()

Detailed Description

handling of XML documents in a DOM like way


Function Documentation

void xmlnode_change_namespace ( xmlnode  node,
const char *  ns_iri 
)

change the namespace of a node

Parameters:
node the node to change the namespace for
ns_iri the new namespace of the node

References xmlnode_t::ns_iri, NS_XMLNS, xmlnode_t::prefix, pstrdup(), xmlnode_get_attrib_ns(), xmlnode_pool(), and xmlnode_put_attrib_ns().

Referenced by xdb_file_load().

xmlnode xmlnode_dup ( xmlnode  x  ) 

produce full duplicate of x with a new pool

Note:
x must be a tag!
Parameters:
x xmlnode (tag) that should be duplicated using a new memory pool
Returns:
pointer to the duplicated tree, or NULL on error

References xmlnode_t::name, xmlnode_t::ns_iri, xmlnode_t::prefix, xmlnode_get_firstattrib(), xmlnode_get_firstchild(), xmlnode_has_children(), xmlnode_insert_node(), and xmlnode_new_tag_ns().

Referenced by dialback_out_connection_cleanup(), dialback_out_read(), dpacket_copy(), and js_mapi_create_additional_iq_result().

xmlnode xmlnode_dup_pool ( pool  p,
xmlnode  x 
)

produce a full duplicate of a x using the specified memory pool

Note:
this is nearly the same as xmlnode_dup(), with the difference, that you can specify which memory pool to use
Parameters:
p memory pool to use
x xmlnode (tag) that should be duplicated
Returns:
pointer to the duplicated tree, or NULL on error

References xmlnode_t::name, xmlnode_t::ns_iri, xmlnode_t::prefix, xmlnode_get_firstattrib(), xmlnode_get_firstchild(), xmlnode_has_children(), xmlnode_insert_node(), and xmlnode_new_tag_pool_ns().

void xmlnode_free ( xmlnode  node  ) 
char* xmlnode_get_attrib ( xmlnode  owner,
const char *  name 
)

get an attribute value

Deprecated:
This function is not aware of namespaces, use xmlnode_get_attrib_ns() instead
Parameters:
owner element where to look for the attribute
name name of the attribute of which the value should be returned
Returns:
value of the attribute, or NULL if no such attribute

References j_strcmp(), j_strncmp(), NS_XMLNS, and xmlnode_get_attrib_ns().

Referenced by dnsrv_deliver(), js_bounce_xmpp(), xdb_file_phandler(), and xmlnode_get_tag().

char* xmlnode_get_attrib_ns ( xmlnode  owner,
const char *  name,
const char *  ns_iri 
)
char* xmlnode_get_data ( xmlnode  node  ) 
xmlnode xmlnode_get_firstattrib ( xmlnode  parent  ) 

get the first attribute node of an element

iteration on all attributes is possible by using xmlnode_get_nextsibling() using the result of this function as the start

Parameters:
parent element for which the first attribute node should be returned
Returns:
attribute node

References xmlnode_t::firstattrib.

Referenced by xmppd::ns_decl_list::ns_decl_list(), xmlnode_dup(), xmlnode_dup_pool(), xmlnode_get_tags(), and xmlnode_insert_tag_node().

xmlnode xmlnode_get_firstchild ( xmlnode  parent  ) 
const char* xmlnode_get_lang ( xmlnode  node  ) 
xmlnode xmlnode_get_lastchild ( xmlnode  parent  ) 

get the last child node of a node

(backwards) iteration on all childs is possible using xmlnode_get_prevsibling() using the result of this function as the start

Parameters:
parent element for which the last child should be returned
Returns:
last child node

References xmlnode_t::lastchild.

Referenced by dnsrv().

xmlnode xmlnode_get_list_item ( const xmlnode_vector first,
unsigned int  i 
)

get the (i+1)-th element in a list of xmlnodes

Parameters:
first first list item
i which item to get (we start counting at zero)
Returns:
the node of the list item, NULL if no such item

Referenced by _js_authreg_register(), _js_session_from(), _js_session_to(), dialback(), dialback_in_verify(), dialback_out_read(), dialback_packets(), jsm(), jutil_priority(), main(), mio_init(), mod_offline(), mod_version(), pthsock_client(), register_instance(), xdb_file(), xdb_file_phandler(), xdb_sql(), and xhash_from_xml().

char* xmlnode_get_list_item_data ( const xmlnode_vector first,
unsigned int  i 
)

get that text wrapped by the (i+1)-th element in a list of xmlnodes

Parameters:
first pointer to the first list item
i which item to use
Returns:
textual content, or NULL if no textual content, or item not found

References xmlnode_get_data().

Referenced by dialback(), and xdb_file().

const char* xmlnode_get_localname ( xmlnode  node  ) 
char* xmlnode_get_name ( xmlnode  node  ) 

get the name of a node

Deprecated:
This function mimics the jabberd 1.4.x xmlnode_get_name() where the name including the prefix is returned. You probably do not want to use this in a namespace aware application. You might want to use xmlnode_get_localname(), and xmlnode_get_namespace() instead.
Parameters:
node the node to get the name for
Returns:
name of the node

References xmlnode_t::name, xmlnode_t::p, xmlnode_t::prefix, and pstrdup().

Referenced by configo(), dialback_packets(), and xmlnode_get_tag().

const char* xmlnode_get_namespace ( xmlnode  node  ) 
xmlnode xmlnode_get_nextsibling ( xmlnode  sibling  ) 
const char* xmlnode_get_nsprefix ( xmlnode  node  ) 

get the namespace prefix of a node

Note:
normally you will not need this. To compare two nodes, just compare the namespace (xmlnode_get_namespace()) and the localname (xmlnode_get_localname())
Parameters:
node the node to get the namespace prefix for
Returns:
namespace prefix of the node, NULL for the default prefix

References xmlnode_t::prefix.

Referenced by main().

xmlnode xmlnode_get_parent ( xmlnode  node  ) 

get the parent node for a node

Parameters:
node the node for which the parent node should be returned
Returns:
parent node

References xmlnode_t::parent.

Referenced by expat_endElement(), main(), and xmlnode_get_tags().

xmlnode xmlnode_get_prevsibling ( xmlnode  sibling  ) 

return the previous sibling

this can be used together with xmlnode_get_lastchild() to iterate backwards over the childrens of a node

Parameters:
sibling the node to get the previous sibling for
Returns:
previous sibling

References xmlnode_t::prev.

Referenced by dnsrv().

xmlnode xmlnode_get_tag ( xmlnode  parent,
const char *  name 
)

find given tag in an xmlnode tree

Deprecated:
This function is not aware of namespaces, use xmlnode_get_tags(), and xmlnode_get_list_item() instead
Parameters:
parent pointer to the parent tag
name "name" for the child tag of that name, "name/name" for a sub child (recurses), "?attrib" to match the first tag with that attrib defined, "?attrib=value" to match the first tag with that attrib and value, "=cdata" to match the text node contents of the child, or any combination: "name/name/?attrib", "name=cdata", etc
Returns:
a pointer to the tag matching search criteria, or NULL if search was unsuccessfull

References xmlnode_t::firstchild, j_strcmp(), NTYPE_TAG, xmlnode_get_attrib(), xmlnode_get_data(), xmlnode_get_name(), xmlnode_get_nextsibling(), xmlnode_get_tag(), and xmlnode_get_type().

Referenced by jsm(), xdb_file_phandler(), xmlnode_get_tag(), and xmlnode_get_tag_data().

char* xmlnode_get_tag_data ( xmlnode  parent,
const char *  name 
)

return the text wrapped inside the element found by the name parameter

this equals xmlnode_get_data(xmlnode_get_tag(parent, name))

Deprecated:
This function is not aware of namespaces, use xmlnode_get_tags(), and xmlnode_get_list_item_data() instead
Parameters:
parent the element where to search for the element defined by the name parameter
name search query for the element whichs textual content should be returned
Returns:
textual content, or NULL if no textual content

References xmlnode_get_data(), and xmlnode_get_tag().

xmlnode_vector xmlnode_get_tags ( xmlnode  context_node,
const char *  _path,
xht  namespaces 
)

at all xmlnodes that match a path

The valid paths are a very small subset of xpath.

The only predicates we support is for existence of attributes, or for attribute values, we only support steps in the axis child and the axis must be ommited, we support text() as a step.

Examples:

  • foo/bar/text()
  • foo/bar[@baz='true']/text()
  • foobar
  • foobar[@attribute]
  • *[@attribute='value']
Parameters:
context_node the xmlnode where to start the path
path the path (xpath like syntax, but only a small subset)
namespaces hashtable mapping namespace prefixes to namespace IRIs
p memory pool to use
Returns:
first item in the list of xmlnodes, or NULL if no xmlnode matched the path

References j_strcmp(), xmlnode_t::name, xmlnode_t::ns_iri, NTYPE_CDATA, xmlnode_t::type, xhash_get(), xmlnode_get_firstattrib(), xmlnode_get_firstchild(), xmlnode_get_nextsibling(), and xmlnode_get_parent().

Referenced by _js_authreg_register(), _js_session_from(), _js_session_to(), acl_get_users(), configurate(), deliver(), deliver_config_filter(), dialback(), dialback_in_verify(), dialback_out_read(), dialback_packets(), js_config(), jsm(), jsm_deserialize(), jutil_priority(), main(), mio_init(), mod_offline(), mod_version(), mod_xml(), pthsock_client(), register_instance(), xmppd::resolver::resend_service::resend_service(), xdb_file(), xdb_file_phandler(), xdb_sql(), and xhash_from_xml().

int xmlnode_get_type ( xmlnode  node  ) 
int xmlnode_has_children ( xmlnode  node  ) 

check if a node has child nodes

Parameters:
node the node to check
Returns:
1 if the node has childrens, 0 else

References xmlnode_t::firstchild.

Referenced by xmlnode_dup(), xmlnode_dup_pool(), xmlnode_insert_tag_node(), and xstream_header_char().

void xmlnode_hide ( xmlnode  child  ) 

hide (remove) a node from a document

Note:
the root element of a document cannot be hidden with this function
Parameters:
child the xmlnode that should be hidden

References xmlnode_t::firstattrib, xmlnode_t::firstchild, xmlnode_t::lastattrib, xmlnode_t::lastchild, xmlnode_t::next, NTYPE_ATTRIB, xmlnode_t::parent, xmlnode_t::prev, and xmlnode_t::type.

Referenced by deliver_fail(), dialback_in_read_db(), dialback_in_verify(), dialback_out_read(), jutil_iqresult(), main(), and xdb_file_phandler().

void xmlnode_hide_attrib ( xmlnode  parent,
const char *  name 
)

hide (remove) an attribute of an element

Deprecated:
This function is not aware of namespaces. Use xmlnode_hide_attrib_ns() instead.
Parameters:
parent the element for which an attribute should be hidden
name name of the attribute, that should be hidden

References j_strncmp(), NS_XMLNS, and xmlnode_hide_attrib_ns().

void xmlnode_hide_attrib_ns ( xmlnode  parent,
const char *  name,
const char *  ns_iri 
)

hide (remove) a namespaced attribute of an element

Parameters:
parent the element for which an attribute should be hidden
name local name of the attribute, that should be hidden
ns_iri namespace IRI of the attribute, that should be hidden

References xmlnode_t::firstattrib, xmlnode_t::lastattrib, xmlnode_t::next, NTYPE_ATTRIB, and xmlnode_t::prev.

Referenced by _js_routed_packet(), _js_session_from(), _js_session_to(), dialback_out_packet(), dialback_out_read(), dialback_packets(), jpacket_reset(), js_authreg(), xdb_file_phandler(), and xmlnode_hide_attrib().

xmlnode xmlnode_insert_cdata ( xmlnode  parent,
const char *  CDATA,
unsigned int  size 
)

insert a text node as child to an existing xmlnode

Parameters:
parent where to insert the new text node
CDATA content of the text node to insert
size size of the string in CDATA, or -1 for auto-detection on null-terminated strings
Returns:
a pointer to the new child node, or NULL if it was unsuccessfull

References xmlnode_t::data, xmlnode_t::data_sz, NTYPE_CDATA, xmlnode_t::p, and pmalloc().

Referenced by _mio_xstream_CDATA(), configurate(), dialback_in_read(), dialback_out_connection(), dialback_out_read(), dnsrv_lookup(), expat_charData(), js_bounce_xmpp(), jutil_delay(), jutil_error_xmpp(), jutil_msgnew(), jutil_presnew(), log_generic(), logger(), main(), xmlnode_insert_node(), and xstream_eat().

void xmlnode_insert_node ( xmlnode  parent,
xmlnode  node 
)
xmlnode xmlnode_insert_tag ( xmlnode  parent,
const char *  name 
)

append a child tag to a tag

Deprecated:
This function is not aware of namespaces, use xmlnode_insert_tag_ns() instead
Parameters:
parent the xmlnode where the new element should be inserted
name name of the child tag
Returns:
pointer to the child tag node, or NULL if it was unsuccessfull

References xmlnode_t::ns_iri, NTYPE_TAG, pmalloco(), xmlnode_t::prefix, and xmlnode_pool().

xmlnode xmlnode_insert_tag_node ( xmlnode  parent,
xmlnode  node 
)

copy an element node as a child to an other node

Parameters:
parent where to insert the xmlnode
node node to insert
Returns:
pointer to the copied xmlnode

References xmlnode_t::name, xmlnode_t::ns_iri, xmlnode_t::prefix, xmlnode_get_firstattrib(), xmlnode_get_firstchild(), xmlnode_has_children(), xmlnode_insert_node(), and xmlnode_insert_tag_ns().

Referenced by configurate(), dialback_in_read_db(), dialback_out_packet(), xdb_file_phandler(), and xmlnode_insert_node().

xmlnode xmlnode_insert_tag_ns ( xmlnode  parent,
const char *  name,
const char *  prefix,
const char *  ns_iri 
)

append a child tag to a tag, including namespace declaration

Parameters:
parent the xmlnode where the new element should be inserted
name local name of the child tag
prefix namespace prefix of the child tag
ns_iri namespace IRI of the child tag
Returns:
pointer to the child tag node, or NULL if it was unsuccessfull

References j_strcmp(), NS_CLIENT, NS_COMPONENT_ACCEPT, NS_SERVER, NS_XMLNS, NTYPE_TAG, xmlnode_t::prefix, and xmlnode_put_attrib_ns().

Referenced by _dialback_walk_in_connecting(), _dialback_walk_in_established(), _dialback_walk_out_connecting(), _dialback_walk_out_established(), _js_authreg_auth(), _js_authreg_register(), configurate(), deliver_fail(), dialback_in_read(), expat_startElement(), js_bounce_xmpp(), js_mapi_create_additional_iq_result(), js_session_route(), jutil_delay(), jutil_error_xmpp(), jutil_iqnew(), jutil_msgnew(), jutil_presnew(), xdb_file_phandler(), and xmlnode_insert_tag_node().

xmlnode xmlnode_new_tag ( const char *  name  ) 

create a tag node

Deprecated:
This function is not aware of namespaces, use xmlnode_new_tag_ns() instead

Automatically creates a memory pool for the node. The namespace is declared to be 'jabber:server'.

Parameters:
name name of the tag
Returns:
a pointer to the new tag node, or NULL if it was unsuccessfull

References pool_heap, and xmlnode_new_tag_pool().

xmlnode xmlnode_new_tag_ns ( const char *  name,
const char *  prefix,
const char *  ns_iri 
)

create a tag node, including a namespace declaration

Automatically creates a memory pool for the node.

Parameters:
name local name of the tag
prefix the namespace prefix of the tag (NULL for the default prefix)
ns_iri the namespace IRI of the tag
Returns:
a pointer to the new tag node, or NULL if it was unsuccessfull

References pool_heap, and xmlnode_new_tag_pool_ns().

Referenced by dialback_in_read(), dialback_in_read_db(), dialback_ip_set(), dialback_out_connection(), dialback_out_read(), expat_startElement(), js_session_route(), jsm_serialize(), jutil_iqnew(), jutil_msgnew(), jutil_presnew(), log_generic(), logger(), xdb_file_load(), xhash_to_xml(), xmlnode_dup(), xstream_eat(), and xstream_header().

xmlnode xmlnode_new_tag_pool ( pool  p,
const char *  name 
)

create a tag node within given pool

The namespace is declared to be 'jabber:server'.

Deprecated:
This function is not aware of namespaces, use xmlnode_new_tag_pool_ns() instead
Parameters:
p previously created memory pool
name name of the tag
Returns:
a pointer to the tag node, or NULL if it was unsuccessfull

References j_strcmp(), NS_DIALBACK, NS_SERVER, NS_STREAM, NTYPE_TAG, pmalloco(), and pool_cleanup().

Referenced by xmlnode_new_tag().

xmlnode xmlnode_new_tag_pool_ns ( pool  p,
const char *  name,
const char *  prefix,
const char *  ns_iri 
)

create a tag node within a given pool, including a namespace declaration

Parameters:
p previously created memory pool
name local name of the tag
prefix the namespace prefix of the tag (NULL for the default prefix)
ns_iri the namespace IRI of the tag
Returns:
a pointer to the new tag node, or NULL if it was unsuccessfull

References j_strcmp(), NS_CLIENT, NS_COMPONENT_ACCEPT, NS_SERVER, NS_XMLNS, NTYPE_TAG, pool_cleanup(), and xmlnode_put_attrib_ns().

Referenced by dialback_in_read_db(), dialback_in_verify(), dialback_out_connection(), dnsrv_lookup(), xmlnode_dup_pool(), xmlnode_new_tag_ns(), and xmlnode_wrap_ns().

pool xmlnode_pool ( xmlnode  node  ) 
void xmlnode_put_attrib ( xmlnode  owner,
const char *  name,
const char *  value 
)

add an attribute to an xmlnode element

Deprecated:
This function is not aware of namespaces, use xmlnode_put_attrib_ns() instead
Parameters:
owner element to add the attribute to
name name of the attribute
value value of the attribute

References j_strcmp(), j_strncmp(), NS_CLIENT, NS_COMPONENT_ACCEPT, xmlnode_t::ns_iri, NS_SERVER, NS_XML, NS_XMLNS, xmlnode_t::p, xmlnode_t::prefix, pstrdup(), and xmlnode_put_attrib_ns().

Referenced by dnsrv_process_xstream_io().

void xmlnode_put_attrib_ns ( xmlnode  owner,
const char *  name,
const char *  prefix,
const char *  ns_iri,
const char *  value 
)

add an namespaced attribute to an xmlnode element

Parameters:
owner element to add the attribute to
name local name of the attribute
prefix namespace prefix of the attribute
ns_iri namespace IRI of the attribute
value the value to set for the attribute

References xmlnode_t::data, xmlnode_t::data_sz, xmlnode_t::firstattrib, j_strcmp(), xmlnode_t::lastattrib, NS_CLIENT, NS_COMPONENT_ACCEPT, NS_SERVER, NTYPE_ATTRIB, xmlnode_t::p, xmlnode_t::parent, and pstrdup().

Referenced by _dialback_walk_in_connecting(), _dialback_walk_in_established(), _dialback_walk_out_connecting(), _dialback_walk_out_established(), _js_authreg_auth(), _js_authreg_register(), _js_routed_auth_packet(), _js_routed_session_control_packet(), _js_routed_session_packet(), _js_session_from(), _js_session_to(), base_syslog_config(), configurate(), deliver_fail(), dialback_in_read(), dialback_in_read_db(), dialback_in_verify(), dialback_ip_set(), dialback_out_connection(), dialback_out_packet(), dialback_out_read(), dialback_packets(), dnsrv_child_process_xstream_io(), dnsrv_resend(), js_authreg(), js_bounce_xmpp(), js_sc_session_new(), js_session_end(), js_session_new(), js_session_route(), jutil_delay(), jutil_error_xmpp(), jutil_iqnew(), jutil_iqresult(), jutil_msgnew(), jutil_presnew(), jutil_tofrom(), log_generic(), logger(), main(), xdb_file_phandler(), xmlnode_change_namespace(), xmlnode_insert_node(), xmlnode_insert_tag_ns(), xmlnode_new_tag_pool_ns(), xmlnode_put_attrib(), xmlnode_put_expat_attribs(), xmlnode_wrap_ns(), and xstream_header().

xmlnode xmlnode_select_by_lang ( const xmlnode_vector nodes,
const char *  lang 
)

select one note from a list of notes by language

This picks the first node in the list with the specified language, if no such node exists, the language in general is searched (e.g. if lang is fr-FR, we then look for fr). If even no such node exists, the first node without a language is selected, if no nodes without a language are in the list, the first list item is returned.

Parameters:
nodes pointer to the first entry in the list of nodes
lang language to prefere (if NULL, the first node without language is prefered)
Returns:
the selected nodes, NULL if no nodes have been passed

References j_strcasecmp(), and xmlnode_get_lang().

Referenced by js_config().

char* xmlnode_serialize_string ( xmlnode_t const *  node,
const xmppd::ns_decl_list nslist,
int  stream_type 
)

serialize a given xmlnode to a string

This function can be used to serialize a stanza. As a stanza is typically written to an XML stream, there might be namespaces, that are already declared by the stream root element. These namespaces do not need to be declared again, when the stanza is serialized. This is what nslist_first and nslist_last is for. These two pointers point to the begin and end of a list of already declared namespace prefixes. If all namespaces should be declared, than you can just pass NULL as these two arguments.

Do not pass the 'jabber:client', or 'jabber:component:accept' namespace in the list of already declared namespaces, but pass always the namespace 'jabber:server' instead. This is because xmlnode represents all these namespaces as 'jabber:server'.

Note:
while xmlnode_serialize_string() is running, the list passed by the arguments nslist_first and nslist_last gets expanded, but when returning, the list is restored. Keep this in mind in a multithreading environment.
Internally xmlnode converts the namespaces 'jabber:client' and 'jabber:component:accept' to the namespace 'jabber:server'. This is done to be able to easily serialize the same stanza on client streams, server streams, as well as streams where components are connected. When serializing the xmlnode, the namespace 'jabber:server' is serialized as the right namespace. This is controled by the stream_type argument.
Parameters:
node the base xmlnode of the tree, that should be serialized
nslist list of already declared namespaces
stream_type 0 for a 'jabber:server' stream, 1 for a 'jabber:client' stream, 2 for a 'jabber:component:accept' stream
Returns:
serialized XML tree

References pstrdup(), and xmlnode_pool().

Referenced by _js_routed_packet(), deliver(), deliver_fail(), dialback_in_read(), dialback_in_read_db(), dialback_in_verify(), dialback_miod_read(), dialback_out_packet(), dialback_out_read(), dnsrv(), dnsrv_child_process_xstream_io(), dnsrv_deliver(), dnsrv_lookup(), dnsrv_process_xstream_io(), dpacket_new(), js_bounce_xmpp(), js_deliver(), js_offline_main(), js_packet(), js_server_main(), log_generic(), logger(), main(), mio_init(), mio_write(), mod_dynamic(), xdb_file(), xdb_file_phandler(), xmlnode2file_limited(), and xstream_header_char().

void xmlnode_stat (  ) 

Referenced by main().

xmlnode xmlnode_wrap ( xmlnode  x,
const char *  wrapper 
)

wrap a xmlnode in a new element

this function creates a new element with the name specified as the wrapper parameter, the xmlnode x becomes a child of this new element

Deprecated:
This function is not aware of namespaces. Use xmlnode_wrap_ns() instead.
Parameters:
x the xmlnode that gets wrapped
wrapper name of the wrapping element (that is to be created)
Returns:
the new element, that is wrapping x

References NS_SERVER, xmlnode_t::p, pmalloco(), xmlnode_t::prefix, and xmlnode_wrap_ns().

xmlnode xmlnode_wrap_ns ( xmlnode  x,
const char *  name,
const char *  prefix,
const char *  ns_iri 
)

wrap an xmlnode in a new namespaced element

this function creates a new element with the specified namespace and name, the xmlnode x becomes a child of this new element

Parameters:
x the xmlnode that gets wrapped
name the local name of the wrapper element (that is to be created)
prefix the namespace prefix of the wrapper element
ns_iri the namespace IRI of the wrapper element
Returns:
the new element, that is wrapping x

References xmlnode_t::firstchild, xmlnode_t::lastchild, NS_XML, xmlnode_t::p, xmlnode_t::parent, xmlnode_get_lang(), xmlnode_new_tag_pool_ns(), and xmlnode_put_attrib_ns().

Referenced by dialback_in_read_db(), dnsrv_resend(), js_authreg(), js_session_route(), and xmlnode_wrap().


Generated on Thu Mar 11 06:00:06 2010 for jabberd14 by  doxygen 1.6.1