pdk.flow.xml.XmlAttr
contains functions to operate with XML Attr variables
This functions are based on Java org.w3c.dom
package classes.
https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/package-summary.html
You can always rely on Java documentation and examples!
You can use functions from the pdk.floe.xml.XmlNode package for variables of type Attr, as the pdk.net.xml.Attr structure extends the pdk.net.xml.Node.
Attr objects inherit the Node structure, but since they are not actually child nodes of the element they describe, the DOM does not consider them part of the document tree. Thus, the Node attributes parentNode
, previousSibling
, and nextSibling
have a null
value for Attr objects. The DOM takes the view that attributes are properties of elements rather than having a separate identity from the elements they are associated with; this should make it more efficient to implement such features as default attributes associated with all elements of a given type. Furthermore, Attr nodes may not be immediate children of a DocumentFragment. However, they can be associated with Element nodes contained within a DocumentFragment. In short, users and implementors of the DOM need to be aware that Attr nodes have some things in common with other objects inheriting the Node structure, but they also are quite distinct.
The attribute's effective value is determined as follows: if this attribute has been explicitly assigned any value, that value is the attribute's effective value; otherwise, if there is a declaration for this attribute, and that declaration includes a default value, then that default value is the attribute's effective value; otherwise, the attribute does not exist on this element in the structure model until it has been explicitly added. Note that the Node.nodeValue
attribute on the Attr instance can also be used to retrieve the string version of the attribute's value(s).
If the attribute was not explicitly given a value in the instance document but has a default value provided by the schema associated with the document, an attribute node will be created with specified
set to false
. Removing attribute nodes for which a default value is defined in the schema generates a new attribute node with the default value and specified
set to false
. If validation occurred while invoking XmlDocument.normalizeDocument(), attribute nodes with specified
equals to false
are recomputed according to the default attribute values provided by the schema. If no default value is associate with this attribute in the schema, the attribute node is discarded.
In XML, where the value of an attribute can contain entity references, the child nodes of the Attr node may be either Text or EntityReference nodes.
The following table gives some examples of the relations between the attribute value in the original document (parsed attribute), the value as exposed in the DOM, and the serialization of the value:
Character reference
Built-in character entity
Literal newline between
Normalized newline between
All functions
getName
Returns the name of the input attribute. If result of XmlNode.localName function is different from null
, this attribute is a qualified name.
Arguments:
attribute :: pdk.net.xml.Attr
Result:
output :: pdk.core.String
Possible exceptions
NullPointerException - throws if the input attribute is
NULL
Example:
XML Document
getSpecified
True
if this attribute was explicitly given a value in the instance document, false
otherwise. If the application changed the value of this attribute node (even if it ends up having the same value as the default value) then it is set to true
. The implementation may handle attributes with default values from other schemas similarly but applications should use XmlDocument.normalizeDocument function to guarantee this information is up-to-date.
Arguments:
attribute :: pdk.net.xml.Attr
Result:
output :: pdk.core.Boolean
Possible exceptions
NullPointerException - throws if the input attribute is
NULL
Example:
XML Document
getValue
On retrieval, the value of the attribute is returned as a string. Character and general entity references are replaced with their values. See also the function XmlElement.getAttribute.
Arguments:
attribute :: pdk.net.xml.Attr
Result:
output :: pdk.core.String
Possible exceptions
NullPointerException - throws if the input attribute is
NULL
Example:
XML Document
setValue
Creates a Text node with the unparsed contents of the string, i.e. any characters that an XML processor would recognize as markup are instead treated as literal text. See also the function XmlElement.setAttribute. Some specialized implementations, such as some [SVG 1.1] implementations, may do normalization automatically, even after mutation; in such case, the value on retrieval may differ from the value on setting.
Arguments:
attribute :: pdk.net.xml.Attr
newValue :: pdk.core.String
Result:
No variable is returned. The input attribute value has been changed
Possible exceptions
NullPointerException - throws if the input attribute is
NULL
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly
Example:
XML Document
getOwnerElement
The Element node this attribute is attached to or null
if this attribute is not in us
Arguments:
attribute :: pdk.net.xml.Attr
Result:
output :: pdk.net.xml.Element
Possible exceptions
NullPointerException - throws if the input attribute is
NULL
Example:
XML Document
getSchemaTypeInfo
The type information associated with this attribute. While the type information contained in this attribute is guarantee to be correct after loading the document or invoking XmlDocument.normalizeDocument function, schemaTypeInfo
may not be reliable if the node was moved.
Arguments:
attribute :: pdk.net.xml.Attr
Result:
output :: pdk.net.xml.TypeInfo
Possible exceptions
NullPointerException - throws if the input attribute is
NULL
isId
Returns whether this attribute is known to be of type ID (i.e. to contain an identifier for its owner element) or not. When it is and its value is unique, the ownerElement
of this attribute can be retrieved using the method XmlDocument.getElementById
Arguments:
attribute :: pdk.net.xml.Attr
Result:
output :: pdk.core.Boolean
Possible exceptions
NullPointerException - throws if the input attribute is
NULL
Last updated