Try OpenEdge Now
skip to main content
Working with XML
Reading XML Documents with the Simple API for XML (SAX) : Understanding ABL SAX : SAX-attributes object
 

SAX-attributes object

When the parser encounters the start tag of a new XML element, it knows to call the startElement callback procedure. At this time, the parser creates a SAX-attributes object and passes it to the startElement callback as an input parameter. Thus, when you define your startElement callback, you define the name of the parameter that holds the handle to this automatically created object and this is how your callback can access the attributes of the XML element.
For example, suppose the parser encounters an XML start tag that has one or more attributes, such as:
<Customer name="John Smith" id="2543">
The parser creates and populates the StartElement callback attributes parameter with information on the XML element's attributes. In the example, name and id are attributes. The attributes parameter is a handle to a SAX-attributes object.
Note: The SAX-attributes object is similar to the Attributes interface of the Java Sax2 API.
For most basic use cases, you will be working with this automatically created SAX-attributes object. For information on programmatically creating your own SAX-attributes object, see Creatinga SAX-attributes object.
The following table summarizes the attributes and methods of the SAX-attributes object. For complete reference entries, see OpenEdge Development: ABL Reference.
Table 8. SAX-attributes attribute and method summary
This attribute or method . . .
Lets you . . .
NUM-ITEMS attribute
See how many attributes the XML element has
GET-INDEX-BY-NAMESPACE-NAME( ) method
GET-INDEX-BY-QNAME( ) method
Get where on the attribute list a particular attribute resides
GET-LOCALNAME-BY-INDEX( ) method
GET-QNAME-BY-INDEX( ) method
GET-URI-BY-INDEX( ) method
Get the name of a particular attribute
GET-TYPE-BY-INDEX( ) method
GET-TYPE-BY-NAMESPACE-NAME( ) method
GET-TYPE-BY-QNAME(  ) method
Get the type of a particular attribute
GET-VALUE-BY-INDEX( ) method
GET-VALUE-BY-NAMESPACE-NAME( ) method
GET-VALUE-BY-QNAME( ) method
Get the value of a particular attribute
INSERT-ATTRIBUTE( ) method
UPDATE-ATTRIBUE( ) method
REMOVE-ATTRIBUTE( ) method
Manipulate the attributes in the list
TYPE attribute
Get the type of the object (which is always SAX-ATTRIBUTES)
ADM-DATA attribute
HANDLE attribute
INSTANTIATING-PROCEDURE attribute
PRIVATE-DATA attribute
UNIQUE-ID attribute
Get or set information concerning this particular SAX-attributes object
COPY-SAX-ATTRIBUTES( ) method
Copy the contents of the specified SAX-attributes object to this SAX-attributes object
A SAX-attributes object represents the complete collection of all the attributes for a given element. No matter how many attributes an element has, the StartElement callback gets passed only one SAX-attributes handle.
Note: The order of the elements in the SAX-attributes object list might not be the same as the order in which they appear in the document—which is consistent with the SAX2 Java API specification.
* Retrieving data from a SAX-attributes object
* Creating a SAX-attributes object