AddAttribute (XmlNode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 7: Line 7:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th><i>%nod</i></th>
<tr><th><i>%nod</i></th>
<td>If specified, an XmlNode that is set to point to the Attribute node that is added. </td></tr>
<td>If specified, an <var>XmlNode</var> that is set to point to the Attribute node that is added. </td></tr>
<tr><th><i>nod</i></th>
<tr><th><i>nod</i></th>
<td>XmlNode that points to the Element node parent of the added Attribute. </td></tr>
<td><var>XmlNode</var> that points to the Element node parent of the added Attribute. </td></tr>
<tr><th><i>name</i></th>
<tr><th><i>name</i></th>
<td>A Unicode string that is the name of the added Attribute.
<td>A <var>Unicode</var> string that is the name of the added Attribute.
<p class="code">Multiple Attributes with the same name may '''not''' be added to a single parent Element (in contrast with the Add Element method, which allows multiple Elements with the same name to be added to a single parent Element). The name must conform to the XML syntax rules for an attribute name; the maximum length of each of the prefix part and local name part is 127 characters (100 characters prior to version 7.7 of [[Janus SOAP]]). </td></tr>
<p class="code">Multiple Attributes with the same name may '''not''' be added to a single parent Element (in contrast with the Add Element method, which allows multiple Elements with the same name to be added to a single parent Element). The name must conform to the XML syntax rules for an attribute name; the maximum length of each of the prefix part and local name part is 127 characters (100 characters prior to version 7.7 of [[Janus SOAP]]). </td></tr>
</p>
</p>
<tr><th><i>value</i></th>
<tr><th><i>value</i></th>
<td>A Unicode string that is the value of the added Attribute; stored exactly as is, that is, without whitespace normalization nor conversion of any substring which may be equal to a character or entity reference. </td></tr>
<td>A <var>Unicode</var> string that is the value of the added Attribute; stored exactly as is, that is, without whitespace normalization nor conversion of any substring which may be equal to a character or entity reference. </td></tr>
<tr><th><i>URI</i></th>
<tr><th><i>URI</i></th>
<td>A Unicode string that is the Uniform Resource Identifier of the namespace of the name of the added Attribute. This is an optional argument (see "Usage Notes," below).</td></tr>
<td>A <var>Unicode</var> string that is the Uniform Resource Identifier of the namespace of the name of the added Attribute. This is an optional argument (see "Usage Notes," below).</td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul>
<ul>
<li>Since the return value of AddAttribute is frequently not needed,
<li>Since the return value of <var>AddAttribute</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>Attribute nodes are kept in the order in which they
<li>Attribute nodes are kept in the order in which they
are added.
are added.
<li>As of ''Sirius Mods'' version 7.3, the AddAttribute method arguments may
<li>As of ''Sirius Mods'' version 7.3, the <var>AddAttribute</var> 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]].
<li>If the <i>URI</i> argument is present, it must not be the null string,
<li>If the <i>URI</i> argument is present, it must not be the null string,
<i>name</i> must
<i>name</i> must
contain a prefix, and the XmlDoc's Namespace property must be <tt>On</tt>.
contain a prefix, and the <var>XmlDoc</var>'s Namespace property must be <tt>On</tt>.
If there is no such declaration in effect at the
If there is no such declaration in effect at the
Element pointed to by <i>nod</i> for that prefix, a declaration
Element pointed to by <i>nod</i> for that prefix, a declaration
Line 41: Line 41:
<li>If the <i>URI</i> argument is
<li>If the <i>URI</i> argument is
omitted, <i>name</i>
omitted, <i>name</i>
contains a prefix, and the XmlDoc's Namespace property is <tt>On</tt>,
contains a prefix, and the <var>XmlDoc</var>'s Namespace property is <tt>On</tt>,
there must be a namespace declaration for the prefix in effect at the
there must be a namespace declaration for the prefix in effect at the
element pointed to by <i>nod</i> (otherwise the request is canceled).
element pointed to by <i>nod</i> (otherwise the request is canceled).
<li>To modify the value stored in an Attribute node,
<li>To modify the value stored in an Attribute node,
change the Value property of an XmlNode that points to
change the Value property of an <var>XmlNode</var> that points to
the Attribute node.
the Attribute 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 57: Line 57:
The following fragment adds the attribute named "option"
The following fragment adds the attribute named "option"
to the element pointed to by <tt>%nod</tt>:
to the element pointed to by <tt>%nod</tt>:
<p class="code">%nod:AddAttribute('option', 'abc')
<p class="code">%nod:<var>AddAttribute</var>('option', 'abc')
</p>
</p>
===Request-Cancellation Errors===
===Request-Cancellation Errors===
Line 64: Line 64:
<li><i>Name</i> violates the rules for an
<li><i>Name</i> violates the rules for an
XML attribute name.
XML attribute name.
<li><i>Name</i> is prefixed, but the XmlDoc Namespace property
<li><i>Name</i> is prefixed, but the <var>XmlDoc</var> Namespace property
is None.
is None.
<li><i>Name</i> is the name of an attribute already
<li><i>Name</i> is the name of an attribute already

Revision as of 17:46, 25 January 2011

Add Attribute to Element node (XmlNode class)

[Requires Janus SOAP]


This callable function adds an Attribute node to the method Element node.

Syntax

[%outNod =] nod:AddAttribute( name, value, [uri])

Syntax terms

%nod If specified, an XmlNode that is set to point to the Attribute node that is added.
nod XmlNode that points to the Element node parent of the added Attribute.
name A Unicode string that is the name of the added Attribute.

Multiple Attributes with the same name may not be added to a single parent Element (in contrast with the Add Element method, which allows multiple Elements with the same name to be added to a single parent Element). The name must conform to the XML syntax rules for an attribute name; the maximum length of each of the prefix part and local name part is 127 characters (100 characters prior to version 7.7 of Janus SOAP).

value A Unicode string that is the value of the added Attribute; stored exactly as is, that is, without whitespace normalization nor conversion of any substring which may be equal to a character or entity reference.
URI A Unicode string that is the Uniform Resource Identifier of the namespace of the name of the added Attribute. This is an optional argument (see "Usage Notes," below).

Usage notes

  • Since the return value of AddAttribute is frequently not needed, you may want to Call it instead of saving its return value.
  • Attribute nodes are kept in the order in which they are added.
  • As of Sirius Mods version 7.3, the AddAttribute 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.
  • If the URI argument is present, it must not be the null string, name must contain a prefix, and the XmlDoc's Namespace property must be On. If there is no such declaration in effect at the Element pointed to by nod for that prefix, a declaration is added at that Element, unless it would conflict with an existing declaration at the Element (which cancels the request).
  • If the URI argument is omitted, name contains a prefix, and the XmlDoc's Namespace property is On, there must be a namespace declaration for the prefix in effect at the element pointed to by nod (otherwise the request is canceled).
  • To modify the value stored in an Attribute node, change the Value property of an XmlNode that points to the Attribute 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

The following fragment adds the attribute named "option" to the element pointed to by %nod:

%nod:AddAttribute('option', 'abc')

Request-Cancellation Errors

  • Nod is not an Element node.
  • Name violates the rules for an XML attribute name.
  • Name is prefixed, but the XmlDoc Namespace property is None.
  • Name is the name of an attribute already present in the node pointed to by nod.
  • Name prefixed and Namespace On, but URI missing and no declaration for prefix in scope.
  • Value violates the rules for an XML attribute value (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.
  • URI violates the rules for an absolute Uniform Resource Identifier.
  • URI specified and Namespace property is not On or name is not prefixed.
  • URI specified and prefix of name is declared with a different URI at the Element pointed to by nod (not simply in scope at that Element).
  • Insufficient free space exists in CCATEMP.

See also