Description This method sets the value of a specific attribute for a node. For example, the following XFDL represents a value node:
To change the custom attribute, you would use setAttribute. If the attribute does not already exist, setAttribute will create it and assign the appropriate value.
Note: Do not use setAttribute to set the compute attribute. Instead, use
public void setAttribute (
) throws UWIException;
Table 1. Method parameters
|theNamespaceURI||String||The namespace URI for the attribute. For example:
|theAttribute||String||The local name of the attribute. For example, encoding.|
|theValue||String||The value to assign to the attribute.|
Returns Nothing or throws a generic exception (UWIException) if an error occurs.
Attributes and the null namespace:
If an attribute is on a node in a non-XFDL namespace, and that attribute has no namespace prefix, then the attribute is in the null namespace. For example, the following node is the custom namespace, as is the first attribute, but since the second attribute does not have a namespace prefix, it is in the null namespace:
When an attribute is the null namespace, you may either provide a null value for the namespace URI or use the namespace URI for the containing element.
For example, to indicate user attribute on the processing node, you could use the null namespace or the custom namespace URI.
Attributes and namespace prefixes:
If you refer to an attribute with a namespace prefix, setAttribute first looks for a complete match, including both prefix and attribute name. If it does not find a match, it will look for a matching attribute name that has no prefix but whose containing element has the same namespace.
For example, assume that the custom namespace and the test namespace both resolve to the same URI. In the following case, looking for the id attribute would locate the second attribute (test:id), since it has an explicit namespace declaration:
<custom:processing custom:stage="2" user="tjones">
However, in the next case, the id attribute does not have an explicit namespace declaration. Instead, it inherits the custom namespace. However, since the inherited namespace resolves to the same URI, the id attribute is still located:
<a xmlns:custom="ABC" xmlns:test="ABC">
<custom:myElement id="1" test:id="2">
Example The following example shows a shortcut method that sets a custom data attribute for a specific node. A node and a string containing the contents of the attribute are passed to the method, which then uses setAttribute to set the attribute for the node.
private static void setCustomAttribute(FormNodeP theNode, String theContents)