This is the original SAX1 interface for reporting an element's attributes. Unlike the new {@link org.xml.sax.Attributes Attributes}interface, it does not support Namespace-related information.
When an attribute list is supplied as part of a {@link org.xml.sax.DocumentHandler#startElement startElement}event, the list will return valid results only during the scope of the event; once the event handler returns control to the parser, the attribute list is invalid. To save a persistent copy of the attribute list, use the SAX1 {@link org.xml.sax.helpers.AttributeListImpl AttributeListImpl}helper class.
An attribute list includes only attributes that have been specified or defaulted: #IMPLIED attributes will not be included.
There are two ways for the SAX application to obtain information from the AttributeList. First, it can iterate through the entire list:
public void startElement (String name, AttributeList atts) { for (int i = 0; i < atts.getLength(); i++) { String name = atts.getName(i); String type = atts.getType(i); String value = atts.getValue(i); [...] } }
(Note that the result of getLength() will be zero if there are no attributes.)
As an alternative, the application can request the value or type of specific attributes:
public void startElement (String name, AttributeList atts) { String identifier = atts.getValue("id"); String label = atts.getValue("label"); [...] }@deprecated This interface has been replaced by the SAX2{@link org.xml.sax.Attributes Attributes}interface, which includes Namespace support. @since SAX 1.0 @author David Megginson @version 2.0.1 (sax2r2) @see org.xml.sax.DocumentHandler#startElement startElement @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl
|
|
|
|
|
|