# 22. Virtuoso Functions Guide - XMLAppendChildren

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
xmlagg
xmlattributes
xmladdattribute
xmlappendchildren
xmlconcat
xmlelement
xmlforest
xmlinsertafter
xmlinsertbefore
xmlreplace
xmltype.xmltype
xmltype.createnonsch...
xmltype.createschema...
xmltype.createxml
xmltype.existsnode
xmltype.extract
xmltype.getclobval
xmltype.getnamespace
xmltype.getnumval
xmltype.getrooteleme...
xmltype.getschemaurl
xmltype.getstringval
xmltype.isfragment
xmltype.isschemabase...
xmltype.isschemavali...
xmltype.isschemavali...
xmltype.schemavalida...
xmltype.setschemaval...
xmltype.toobject
xmltype.transform
xmlupdate
xper navigation
createxml
isentity
serialize_to_utf8_xm...
tidy_html
tidy_list_errors
updatexml
xml_add_system_path
xml_auto
xml_auto_dtd
xml_auto_schema
xml_create_tables_fr...
xml_cut
xml_doc_output_optio...
xml_get_system_paths
xml_load_mapping_sch...
xml_load_schema_decl
xml_namespace_scope
xml_persistent
xml_template
xml_tree
xml_tree_doc
xml_tree_doc_media_t...
xml_uri_get
xml_validate_dtd
xml_validate_schema
xml_view_dtd
xml_view_schema
xmlsql_update
xpath_eval
xper_cut
xper_doc
xper_locate_words
xpf_extension
xpf_extension_remove
xquery_eval
xslt
xslt_format_number
xslt_sheet
xslt_stale
xte_head
xte_node
xte_node_from_nodebl...
xte_nodebld_acc
xte_nodebld_final
xte_nodebld_init
xtree_doc
XPATH & XQUERY
Functions Index

## XMLAppendChildren

Modify an XML document by adding new children to the given entity.
XMLAppendChildren (inout source any, in insertion1 any, in insertion2 any, ... , in insertionN any);
Description

The function modifies the XML document of the given source XML tree entity by adding new children to the node specified by the entity. The source entity should be XML tree entity, not "persistent XML" entity. The value of source can be either an element entity or a root entity; source can not be an attribute entity or a leaf entity like text or processing instruction.

The values passed in parameters insertion1... insertionN will be converted into XML nodes according to rules described in section Composing Document Fragments From DOM Function Arguments.

After calling the function, parameter source is still a valid XML entity that points to the modified node. The value passed as source can be used in the rest of caller procedure.

Parameters
source – The XML tree entity whose document should be modified. This document should not be locked (see Changing XML Entities in DOM Style for details).
parameterI – The value to be added as as child node of source.
Return Types

The function returns NULL.

Examples
XMLAppendChildren in a Virtuoso/PL procedure

The sample procedure contains two calls of XMLAppendChildren. First call append three children to a node; second call demonstrates how text nodes can be merged.

    create procedure XMLAppendChildren_demo()
    {
      declare DESCRIPTION varchar (40);
      declare ENTITY, ent any;
      result_names (DESCRIPTION, ENTITY);
      result ('EXAMPLE1', 'Plain appending of some children');
      ent := xpath_eval ('//b', xtree_doc ('<a><b>Hello</b></a>'));
      result ('The document to modify', xpath_eval ('/', ent));
      result ('The node to be extended', ent);
      XMLAppendChildren (ent, xtree_doc ('<comma/>'), ' world', xtree_doc ('<excl/>'));
      result ('The changed document', xpath_eval ('/', ent));
      result ('The original entity is updated', ent);
      result ('EXAMPLE2', 'Appending that cause concatenation of text nodes');
      result_names (DESCRIPTION, ENTITY);
      ent := xpath_eval ('//b', xtree_doc ('<a><b>Hello</b></a>'));
      result ('The document to modify', xpath_eval ('/', ent));
      result ('The node to be extended', ent);
      XMLAppendChildren (ent, ', ', ' world', '!');
      result ('The changed document', xpath_eval ('/', ent));
      result ('The original entity is updated', ent);
    }

    Done. -- 00000 msec.

    XMLAppendChildren_demo()
    DESCRIPTION                               ENTITY
    VARCHAR                                   VARCHAR
    _______________________________________________________________________________

    EXAMPLE1                                  Plain appending of some children
    The document to modify                    <a><b>Hello</b></a>
    The node to be extended                   <b>Hello</b>
    The changed document                      <a><b>Hello<comma /> world<excl /></b></a>
    The original entity is updated            <b>Hello<comma /> world<excl /></b>
    EXAMPLE2                                  Appending that cause concatenation of text nodes
    The document to modify                    <a><b>Hello</b></a>
    The node to be extended                   <b>Hello</b>
    The changed document                      <a><b>Hello,  world!</b></a>
    The original entity is updated            <b>Hello,  world!</b>

    10 Rows. -- 00000 msec.

See Also

XMLReplace

XMLAddAttribute

XMLInsertBefore

XMLInsertAfter