1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2018 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-->
<refentry id="fn_XMLAppendChildren">
<refmeta>
<refentrytitle>XMLAppendChildren</refentrytitle>
<refmiscinfo>xml</refmiscinfo>
</refmeta>
<refnamediv>
<refname>XMLAppendChildren</refname>
<refpurpose>Modify an XML document by adding new children to the given entity.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis id="fsyn_XMLAppendChildren">
<funcprototype id="fproto_XMLAppendChildren">
<funcdef><function>XMLAppendChildren</function></funcdef>
<paramdef>inout <parameter>source</parameter> any</paramdef>
<paramdef>in <parameter>insertion1</parameter> any</paramdef>
<paramdef>in <parameter>insertion2</parameter> any</paramdef>
<paramdef><parameter>...</parameter></paramdef>
<paramdef>in <parameter>insertionN</parameter> any</paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1 id="desc_XMLAppendChildren">
<title>Description</title>
<para>The function modifies the XML document of the given <parameter>source</parameter> XML tree entity by adding new children to
the node specified by the entity. The <parameter>source</parameter> entity should be XML tree entity, not "persistent XML" entity.
The value of <parameter>source</parameter> can be either an element entity or a root entity;
<parameter>source</parameter> can not be an attribute entity or a leaf entity like text or processing instruction.
</para>
<para>
The values passed in parameters <parameter>insertion1</parameter>... <parameter>insertionN</parameter> will be converted into
XML nodes according to rules described in section <link linkend="xmldomtypecasting">Composing Document Fragments From DOM Function Arguments.</link>
</para>
<para>
After calling the function, parameter <parameter>source</parameter> is still a valid XML entity that points to the modified node.
The value passed as <parameter>source</parameter> can be used in the rest of caller procedure.
</para>
</refsect1>
<refsect1 id="params_XMLAppendChildren">
<title>Parameters</title>
<refsect2><title>source</title>
<para>The XML tree entity whose document should be modified.
This document should not be locked (see <link linkend="xmldom">Changing XML Entities in DOM Style</link> for details).
</para>
</refsect2>
<refsect2><title>parameterI</title>
<para>The value to be added as as child node of <parameter>source</parameter>.
</para>
</refsect2>
</refsect1>
<refsect1 id="ret_XMLAppendChildren"><title>Return Types</title>
<para>The function returns NULL.</para>
</refsect1>
<!--
<refsect1 id="errors_XMLAppendChildren">
<title>Errors</title>
<! - - In case of non-function-specific errors, i.e. only common
parameter errors are signalled, comment out the table below
otherwise add the unique error values as individual errorcodes - - >
<para>This function can generate the following errors:</para>
<errorcode></errorcode>
</refsect1>
-->
<refsect1 id="examples_XMLAppendChildren">
<title>Examples</title>
<example id="ex_XMLAppendChildren"><title>XMLAppendChildren in a Virtuoso/PL procedure</title>
<para>The sample procedure contains two calls of <function>XMLAppendChildren</function>.
First call append three children to a node; second call demonstrates how text nodes can be merged.</para>
<screen><![CDATA[
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.
]]>
</screen>
</example>
</refsect1>
<refsect1 id="seealso_XMLAppendChildren">
<title>See Also</title>
<para><link linkend="fn_XMLReplace"><function>XMLReplace</function></link></para>
<para><link linkend="fn_XMLAddAttribute"><function>XMLAddAttribute</function></link></para>
<para><link linkend="fn_XMLInsertBefore"><function>XMLInsertBefore</function></link></para>
<para><link linkend="fn_XMLInsertAfter"><function>XMLInsertAfter</function></link></para>
</refsect1>
</refentry>
|