Adds a new attribute to the specified element.
If an attribute with that name is already present in the element,
its value is changed to be that of the value
parameter.
For the real XML element, the function calls directly the W3C DOM method:
Any error raised by this method will be reported by the function.org.w3c.dom.Element.setAttribute()
For all pseudo-element, except those of #STUB
type,
the function does nothing and only returns the attribute value.
(See also DSMElement.pseudoElement
property.)
You may use this function when you need to alter an XML document
dynamically in memory after it has been loaded from the file.
See also loadXMLDocument()
function.
Note: Changing the value of the attribute with
'xmlns'
name or whose name starts with
'xmlns:'
prefix will alter the list of
the namespace bindings associated with this element known to DocFlex.
For instance, this will be reflected in the list of values returned
by '#DOCUMENT/@namespaces'
attribute.
Also, setting a new value to the 'xmlns'
attribute
will change the default namespace assumed by DocFlex within that element.
Parameters:
element
The element whose attribute is created or altered.
If not specified, the generator context element is assumed,
i.e. the same as the
call: setXMLAttribute(contextElement,attrName,value)
attrName
The attribute name.
value
The new value of the attribute.For the real XML element, the value is converted to string. For
#STUB
element, it is stored as object.
Returns:
The previous value of the attribute.If the element contained no attribute with the specified name, the function returns empty string (or
null
, in case of#STUB
element).
See Also:
removeXMLAttribute(), hasXMLAttribute(),
getXMLAttribute(), loadXMLDocument()