AddAttribute (XmlNode function): Difference between revisions
m (→Syntax terms) |
|||
Line 42: | Line 42: | ||
==Request-cancellation errors== | ==Request-cancellation errors== | ||
This list is not exhaustive: it does <i>not</i> include all the errors that are request cancelling. | |||
<ul> | <ul> | ||
<li>The <var class="term">nod</var> argument is not an <var>Element</var> node. | <li>The <var class="term">nod</var> argument is not an <var>Element</var> node. |
Revision as of 01:57, 1 March 2014
Add Attribute to Element node (XmlNode class)
[Requires Janus SOAP]
Syntax
[%outNod =] nod:AddAttribute( name, value, [uri])
Syntax terms
%outNod | 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 AddElement 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 300 characters (127 characters prior to version 7.9, and 100 characters prior to version 7.7). |
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 with_the XmlDoc API".
- 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 value 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
This list is not exhaustive: it does not include all the errors that are request cancelling.
- The nod argument is not an Element node.
- The name argument 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.
- The value argument violates the rules for an XML attribute value (that is, it contains an invalid character).
Note: 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".
- The uri argument 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.