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
|
<?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_XMLInsertAfter">
<refmeta>
<refentrytitle>XMLInsertAfter</refentrytitle>
<refmiscinfo>xml</refmiscinfo>
</refmeta>
<refnamediv>
<refname>XMLInsertAfter</refname>
<refpurpose>Modify an XML document by inserting new children after the node specified by given entity.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis id="fsyn_XMLInsertAfter">
<funcprototype id="fproto_XMLInsertAfter">
<funcdef><function>XMLInsertAfter</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_XMLInsertAfter">
<title>Description</title>
<para>The function modifies the XML document of the given <parameter>source</parameter> XML tree entity by adding new siblings to
the node specified by the entity. Siblings will be added right after the node.
The <parameter>source</parameter> entity should be XML tree entity, not "persistent XML" entity.
The value of <parameter>source</parameter> should be a node entity;
<parameter>source</parameter> can not be an attribute entity or a root entity.
</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 same node.
The value passed as <parameter>source</parameter> can be used in the rest of caller procedure.
</para>
</refsect1>
<refsect1 id="params_XMLInsertAfter">
<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="errors_XMLInsertAfter">
<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_XMLInsertAfter">
<title>Examples</title>
<example id="ex_XMLInsertAfter"><title>XMLInsertBefore in a Virtuoso/PL procedure</title>
<para>The sample procedure contains two calls of <function>XMLInsertAfter</function>.
First call insert two new element nodes just after the given node; second call demonstrates how text nodes can be merged.</para>
<screen><![CDATA[
create procedure XMLInsertAfter_demo()
{
declare DESCRIPTION varchar (40);
declare ENTITY, ent any;
result_names (DESCRIPTION, ENTITY);
result ('EXAMPLE1', 'Plain inserting of some children');
ent := xpath_eval ('//child0', xtree_doc ('<a><child0></child0></a>'));
result ('The document to modify', xpath_eval ('/', ent));
result ('The place of insertion', ent);
XMLInsertAfter (ent, xtree_doc ('<child1/>'), xtree_doc ('<child2/>'));
result ('The changed document', xpath_eval ('/', ent));
result ('The original node is updated', ent);
result ('EXAMPLE2', 'Appending that cause concatenation of text nodes');
ent := xpath_eval ('//b/text()', xtree_doc ('<a><b>Hello</b></a>'));
result ('The document to modify', xpath_eval ('/', ent));
result ('The place of insertion', ent);
XMLInsertAfter (ent, ', world!');
result ('The changed document', xpath_eval ('/', ent));
result ('The original node is updated', ent);
}
Done. -- 00000 msec.
XMLInsertAfter_demo()
DESCRIPTION ENTITY
VARCHAR VARCHAR
_______________________________________________________________________________
EXAMPLE1 Plain inserting of some children
The document to modify <a><child0 /></a>
The place of insertion <child0 />
The changed document <a><child0 /><child1 /><child2 /></a>
The original node is updated <child0 />
EXAMPLE2 Appending that cause concatenation of text nodes
The document to modify <a><b>Hello</b></a>
The place of insertion Hello
The changed document <a><b>Hello, world!</b></a>
The original node is updated Hello, world!
10 Rows. -- 00000 msec.
]]>
</screen>
</example>
</refsect1>
<refsect1 id="seealso_XMLInsertAfter">
<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_XMLAppendChildren"><function>XMLAppendChildren</function></link></para>
<para><link linkend="fn_XMLInsertBefore"><function>XMLInsertBefore</function></link></para>
</refsect1>
</refentry>
|