AddPI (XmlDoc/XmlNode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 8: Line 8:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%nod</th>
<tr><th>%nod</th>
<td>If specified, an XmlNode that is set to point to the PI node that is added. </td></tr>
<td>If specified, an <var>XmlNode</var> that is set to point to the PI node that is added. </td></tr>
<tr><th>nr</th>
<tr><th>nr</th>
<td>An XmlDoc or XmlNode that refers to the Root or Element node that is the parent of the added PI node. </td></tr>
<td>An <var>XmlDoc</var> or <var>XmlNode</var> that refers to the Root or Element node that is the parent of the added PI node. </td></tr>
<tr><th>name</th>
<tr><th>name</th>
<td>A Unicode string that is the target of the added PI node; this can be thought of as the "name" of the PI. It must conform to the XML syntax rules for a PI target; the maximum length of the name is 127 characters (100 characters prior to version 7.7 of [[Janus SOAP]]). </td></tr>
<td>A <var>Unicode</var> string that is the target of the added PI node; this can be thought of as the "name" of the PI. It must conform to the XML syntax rules for a PI target; the maximum length of the name is 127 characters (100 characters prior to version 7.7 of [[Janus SOAP]]). </td></tr>
<tr><th>value</th>
<tr><th>value</th>
<td>A Unicode string that is the value of the added PI node; stored exactly as is, that is, without whitespace normalization.</td></tr>
<td>A <var>Unicode</var> string that is the value of the added PI node; stored exactly as is, that is, without whitespace normalization.</td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul>
<ul>
<li>Since the return value of AddPI is frequently not needed,
<li>Since the return value of <var>AddPI</var> is frequently not needed,
you may want to Call it instead of saving its return value.
you may want to Call it instead of saving its return value.
<li>Processing of an XmlDoc is likely to be more efficient if
<li>Processing of an <var>XmlDoc</var> is likely to be more efficient if
you add nodes in document
you add nodes in document
order (that is, top-to-bottom, left-to-right).
order (that is, top-to-bottom, left-to-right).
<li>To modify the value stored in an PI node,
<li>To modify the value stored in an PI node,
change the Value property of an XmlNode that points to
change the Value property of an <var>XmlNode</var> that points to
the PI node.
the PI node.
<li>As of ''Sirius Mods'' version 7.3, the method arguments may
<li>As of ''Sirius Mods'' version 7.3, the method arguments may
include only non-null EBCDIC characters that translate to Unicode.
include only non-null EBCDIC characters that translate to <var>Unicode</var>.
As of ''Sirius Mods'' version 7.6, these argument strings are Unicode or are
As of ''Sirius Mods'' version 7.6, these argument strings are <var>Unicode</var> or are
converted to Unicode.
converted to <var>Unicode</var>.
For more information about the effects of this version 7.6
For more information about the effects of this version 7.6
change, see [[Strings and Unicode]].
change, see [[Strings and Unicode]].
Line 40: Line 40:
as the last child of element "b":
as the last child of element "b":
<p class="code">Begin
<p class="code">Begin
%doc is Object XmlDoc
%doc is <var>Object</var> <var>XmlDoc</var>
%doc = New
%doc = New
%doc:LoadXml('<top><a><b>05</b></a></top>')
%doc:LoadXml('<top><a><b>05</b></a></top>')
%n1 is Object XmlNode
%n1 is <var>Object</var> <var>XmlNode</var>
%n1 = %doc:SelectSingleNode('top/a/b')
%n1 = %doc:SelectSingleNode('top/a/b')
Call %n1:AddPI('processing_app', 'ignore pre-2004')
Call %n1:<var>AddPI</var>('processing_app', 'ignore pre-2004')
Call %doc:Print
Call %doc:Print
End
End
Line 77: Line 77:
<ul>
<ul>
<li>[[InsertPIBefore (XmlNode function)|InsertPIBefore]] also adds a PI node.
<li>[[InsertPIBefore (XmlNode function)|InsertPIBefore]] also adds a PI node.
AddPI adds a PI as the last child of the node pointed to by the
<var>AddPI</var> adds a PI as the last child of the node pointed to by the
method object;
method object;
InsertPIBefore adds a PI as the immediately preceding
InsertPIBefore adds a PI as the immediately preceding
sibling of the node pointed to by the method object.
sibling of the node pointed to by the method object.
</ul>
</ul>

Revision as of 17:46, 25 January 2011

Add Processing Instruction to XmlDoc Root or to Element XmlNode (XmlDoc and XmlNode classes)

[Requires Janus SOAP]


This callable function adds a PI (Processing Instruction) node as the last child of the Root node or Element node referenced by the method object.

Syntax

[%nod =] nr:AddPI( name, value)

Syntax terms

%nod If specified, an XmlNode that is set to point to the PI node that is added.
nr An XmlDoc or XmlNode that refers to the Root or Element node that is the parent of the added PI node.
name A Unicode string that is the target of the added PI node; this can be thought of as the "name" of the PI. It must conform to the XML syntax rules for a PI target; the maximum length of the name is 127 characters (100 characters prior to version 7.7 of Janus SOAP).
value A Unicode string that is the value of the added PI node; stored exactly as is, that is, without whitespace normalization.

Usage notes

  • Since the return value of AddPI is frequently not needed, you may want to Call it instead of saving its return value.
  • Processing of an XmlDoc is likely to be more efficient if you add nodes in document order (that is, top-to-bottom, left-to-right).
  • To modify the value stored in an PI node, change the Value property of an XmlNode that points to the PI node.
  • As of Sirius Mods version 7.3, the method arguments may include only non-null EBCDIC characters that translate to Unicode. As of Sirius Mods version 7.6, these argument strings are Unicode or are converted to Unicode. For more information about the effects of this version 7.6 change, see Strings and Unicode.

Example

In the following example, one PI node is added as the last child of element "b":

Begin %doc is Object XmlDoc %doc = New %doc:LoadXml('<top><a>05</a></top>') %n1 is Object XmlNode %n1 = %doc:SelectSingleNode('top/a/b') Call %n1:AddPI('processing_app', 'ignore pre-2004') Call %doc:Print End

The example result, showing the serialized format of the processing instruction, follows:

<top> <a> 05 <?processing_app ignore pre-2004?> </a> </top>

Request-Cancellation Errors

  • Nr is neither the Root nor an Element node.
  • Argument name violates the rules for an XML processing instruction target.
  • Argument value violates the rules for an XML processing instruction value.


See also

  • InsertPIBefore also adds a PI node. AddPI adds a PI as the last child of the node pointed to by the method object; InsertPIBefore adds a PI as the immediately preceding sibling of the node pointed to by the method object.