Interface XMLAttributes
- All Superinterfaces:
Attributes,Attributes2
- All Known Implementing Classes:
XMLAttributesImpl
The XMLAttributes interface defines a collection of attributes for an
element. In the parser, the document source would scan the entire start
element and collect the attributes. The attributes are communicated to the
document handler in the startElement method.
The attributes are read-write so that subsequent stages in the document pipeline can modify the values or change the attributes that are propagated to the next stage.
- Author:
- Andy Clark, IBM
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionintaddAttribute(QName attrName, String attrType, String attrValue) Adds an attribute.getName(int attrIndex) Returns the QName structure of the name.voidGets the fields in the given QName structure with the values of the attribute name at the specified index.getNonNormalizedValue(int attrIndex) voidRemoves all of the attributes.voidremoveAttributeAt(int attrIndex) Removes the attribute at the specified index.voidSets the name of the attribute at the specified index.voidsetSpecified(int attrIndex, boolean specified) Sets whether an attribute is specified in the instance document or not.voidSets the value of the attribute at the specified index.Methods inherited from interface org.xml.sax.Attributes
getIndex, getIndex, getLength, getLocalName, getQName, getType, getType, getType, getURI, getValue, getValue, getValueMethods inherited from interface org.xml.sax.ext.Attributes2
isDeclared, isDeclared, isDeclared, isSpecified, isSpecified, isSpecified
-
Method Details
-
addAttribute
Adds an attribute. The attribute's non-normalized value of the attribute will have the same value as the attribute value until. Also, the added attribute will be marked as specified in the XML instance document unless set otherwise using thesetSpecifiedmethod.Note: If an attribute of the same name already exists, the old values for the attribute are replaced by the new values.
- Parameters:
attrName- The attribute name.attrType- The attribute type. The type name is determined by the type specified for this attribute in the DTD. For example: "CDATA", "ID", "NMTOKEN", etc. However, attributes of type enumeration will have the type value specified as the pipe ('|') separated list of the enumeration values prefixed by an open parenthesis and suffixed by a close parenthesis. For example: "(true|false)".attrValue- The attribute value.- Returns:
- Returns the attribute index.
- See Also:
-
removeAllAttributes
void removeAllAttributes()Removes all of the attributes. This method will also remove all entities associated to the attributes. -
removeAttributeAt
void removeAttributeAt(int attrIndex) Removes the attribute at the specified index.Note: This operation changes the indexes of all attributes following the attribute at the specified index.
- Parameters:
attrIndex- The attribute index.
-
setName
Sets the name of the attribute at the specified index.- Parameters:
attrIndex- The attribute index.attrName- The new attribute name.
-
getName
Gets the fields in the given QName structure with the values of the attribute name at the specified index.- Parameters:
attrIndex- The attribute index.attrName- The attribute name structure to fill in.
-
getName
Returns the QName structure of the name. Because QName is a modifiable data structure, make sure you know what you do when you take this shortcut route.- Parameters:
attrIndex- The attribute index.
-
setValue
Sets the value of the attribute at the specified index. This method will overwrite the non-normalized value of the attribute.- Parameters:
attrIndex- The attribute index.attrValue- The new attribute value.
-
getNonNormalizedValue
- Parameters:
attrIndex- The attribute index.- Returns:
- the non-normalized value of the attribute at the specified index. If
no non-normalized value is set, this method will return the same
value as the
getValue(int)method.
-
setSpecified
void setSpecified(int attrIndex, boolean specified) Sets whether an attribute is specified in the instance document or not.- Parameters:
attrIndex- The attribute index.specified- True if the attribute is specified in the instance document.
-