AddText (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 Text node that is added. </td></tr>
<td>If specified, an <var>XmlNode</var> that is set to point to the Text node that is added. </td></tr>
<tr><th>nod</th>
<tr><th>nod</th>
<td>An XmlNode that points to the Element node parent of the inserted Text node. </td></tr>
<td>An <var>XmlNode</var> that points to the Element node parent of the inserted Text node. </td></tr>
<tr><th>value</th>
<tr><th>value</th>
<td>The content of the Text node. This Unicode string value is stored without any normalization, entity substitution, etc. Prior to ''Sirius Mods'' version 7.6, this is an EBCDIC string.</td></tr>
<td>The content of the Text node. This <var>Unicode</var> string value is stored without any normalization, entity substitution, etc. Prior to ''Sirius Mods'' version 7.6, this is an EBCDIC string.</td></tr>
</table>
</table>


Line 22: Line 22:
another Text node, unless the [[AdjacentText (XmlDoc property)|AdjacentText]] property setting is <tt>Combine</tt>.
another Text node, unless the [[AdjacentText (XmlDoc property)|AdjacentText]] property setting is <tt>Combine</tt>.
<li>As of ''Sirius Mods'' version 7.3, ''value'' may
<li>As of ''Sirius Mods'' version 7.3, ''value'' 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, all [[Janus SOAP]] string arguments and results
As of ''Sirius Mods'' version 7.6, all [[Janus SOAP]] string arguments and results
are Unicode or are converted to Unicode.
are <var>Unicode</var> or are 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]].
<li>Since the return value of AddText is frequently not needed,
<li>Since the return value of <var>AddText</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>To modify the value stored in an Text node,
<li>To modify the value stored in an Text node,
change the Value property of an XmlNode that points to
change the Value property of an <var>XmlNode</var> that points to
the Text node.
the Text node.
<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).
Line 42: Line 42:
(that is, located after element "b") of element "a":
(that is, located after element "b") of element "a":
<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>
%n2 is Object XmlNode
%n2 is <var>Object</var> <var>XmlNode</var>
%ls is longstring
%ls is longstring
%ls ='In general, use Longstring %variables where'-
%ls ='In general, use <var>Longstring</var> %variables where'-
  With ' you might use STRING LEN 255 %variables.'
  With ' you might use STRING LEN 255 %variables.'
%n1 = %doc:SelectSingleNode('top/a')
%n1 = %doc:SelectSingleNode('top/a')
%n2 = %n1:AddText(%ls)
%n2 = %n1:<var>AddText</var>(%ls)
%doc:Print('top')
%doc:Print('top')
End
End
Line 67: Line 67:
   <a>
   <a>
       <b>05</b>
       <b>05</b>
       In general, use Longstring %variables where you might
       In general, use <var>Longstring</var> %variables where you might
       use STRING LEN 255 %variables.
       use STRING LEN 255 %variables.
   </a>
   </a>
Line 95: Line 95:
<ul>
<ul>
<li>[[InsertTextBefore (XmlNode function)|InsertTextBefore]] also adds a Text node.
<li>[[InsertTextBefore (XmlNode function)|InsertTextBefore]] also adds a Text node.
AddText adds a Text as the last child of the node pointed to by the
<var>AddText</var> adds a Text as the last child of the node pointed to by the
method object;
method object;
InsertTextBefore adds a Text as the immediately preceding
InsertTextBefore adds a Text 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 Text child to Element node (XmlNode class)

[Requires Janus SOAP]


This callable function adds a Text node as the last child of the method Element node.

Syntax

[%outNod =] nod:AddText( value)

Syntax terms

%nod If specified, an XmlNode that is set to point to the Text node that is added.
nod An XmlNode that points to the Element node parent of the inserted Text node.
value The content of the Text node. This Unicode string value is stored without any normalization, entity substitution, etc. Prior to Sirius Mods version 7.6, this is an EBCDIC string.

Usage notes

  • If value is the null string, a Text node is not inserted, and %nod is set to Null.
  • A Text node may not be added adjacent to (that is, as a sibling of) another Text node, unless the AdjacentText property setting is Combine.
  • As of Sirius Mods version 7.3, value may include only non-null EBCDIC characters that translate to Unicode. As of Sirius Mods version 7.6, all Janus SOAP string arguments and results are Unicode or are converted to Unicode. For more information about the effects of this version 7.6 change, see Strings and Unicode.
  • Since the return value of AddText is frequently not needed, you may want to Call it instead of saving its return value.
  • To modify the value stored in an Text node, change the Value property of an XmlNode that points to the Text node.
  • 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).

Example

In the following example, a Text node is added as the last child (that is, located after element "b") of element "a":

Begin %doc is Object XmlDoc %doc = New %doc:LoadXml('<top><a>05</a></top>') %n1 is Object XmlNode %n2 is Object XmlNode %ls is longstring %ls ='In general, use Longstring %variables where'- With ' you might use STRING LEN 255 %variables.' %n1 = %doc:SelectSingleNode('top/a') %n2 = %n1:AddText(%ls) %doc:Print('top') End

The example result follows. Note that this XML document structure (element "a" having "mixed content", both an Element and Text child) is common to document usage with XML. But it is unusual for data usage with XML (in fact, the SOAP standard disallows mixed content):

.in -1 <top> <a> 05 In general, use Longstring %variables where you might use STRING LEN 255 %variables. </a> </top> .in 0

Request-Cancellation Errors

  • Nod does not point to an Element node.
  • Nod points to an Element node whose last child is a Text node, and the AdjacentText property setting is Disallow.
  • Value violates the rules for XML Element content (that is, it contains an invalid character). Note that as of Sirius Mods version 7.6, this check can no longer be bypassed using the InvalidChar method — see Usage Notes for the InvalidChar property.
  • Insufficient free space exists in CCATEMP.


See also

  • InsertTextBefore also adds a Text node. AddText adds a Text as the last child of the node pointed to by the method object; InsertTextBefore adds a Text as the immediately preceding sibling of the node pointed to by the method object.