Progress
External Program
Interfaces


SAX-ATTRIBUTES Object

When the parser encounters an XML Start-Tag that has one or more attributes, such as:

<Entry name=”John Smith” id=”2543”> 

it populates the Start Element callback’s attributes parameter with information on the element’s attributes (in the example, “name” and “id”). In Progress, the attributes parameter is a handle to a Progress SAX-ATTRIBUTES object, which is similar to the Attributes interface of the Java Sax2 API.

All SAX-ATTRIBUTES objects are created and destroyed by Progress. The application cannot create a SAX-ATTRIBUTES object. The application can, however, store data residing in the SAX-ATTRIBUTES object in data items under the control of the application.

The attributes and methods associated with the SAX-ATTRIBUTES object are summarized in Table 12–3. For reference entries, see the Progress Version 9 Product Update Bulletin .

Table 12–3: SAX-ATTRIBUTES Attribute and Method Summary
This Attribute or Method...
Lets you...
NUM-ITEMS Attribute
Get 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
TYPE Attribute
Get the type of the object (which is always “SAX-ATTRIBUTE”)
ADM-DATA Attribute
PRIVATE-DATA Attribute
UNIQUE-ID Attribute
Get or set information concerning this particular SAX-ATTRIBUTES object

A SAX-ATTRIBUTES object is a collection of all the attributes for a given element. No matter how many attributes an element has, StartElement gets passed only one attributes handle. Think of it as a list of the attributes associated with the element,

NOTE: The order of the elements on the 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.

To get the information about each attribute from a SAX-ATTRIBUTES object, use the GET-XXX methods. They let your application to get the SAX-ATTRIBUTES data in either of two different ways:

There are 6 pieces of information you can get on each attribute, though three are variations on the name. Each GET-XXX method gets you one piece of information. The six pieces of information and the GET-XXX methods are explained in Table 12–4.

Table 12–4: The GET-XXX Methods
To Get This Information
On an Attribute...
Use These Methods...
Its position on the list
GET-INDEX-BY-NAMESPACE-NAME()
GET-INDEX-BY-QNAME()
Its Namespace URI, if namespace information is available
GET-URI-BY-INDEX()
Its localName, if namespace processing is being enabled
GET-LOCALNAME-BY-INDEX()
Its Qualified name (qName)
GET-QNAME-BY-INDEX()
Its XML attribute type (declared in the DTD)
GET-TYPE-BY-INDEX()
GET-TYPE-BY-NAMESPACE-NAME()
GET-TYPE-BY-QNAME()
Its value
GET-VALUE-BY-INDEX()
GET-VALUE-BY-NAMESPACE-NAME()
GET-VALUE-BY-QNAME()

If the parser is doing Namespace processing — that is, if SAX-READER’s SUPPRESS-NAMESPACE-PROCESSING attribute is set to “NO” (the default) — each attribute that has a namespace prefix will have non-empty URI, localName, and qName data. An attribute that has noNamespace prefix will have an empty URI, but its localName and qName will have values.

NOTE: An unprefixed attribute name does not use the default Namespace, if any; it is not associated with any Namespace. This contrasts with the case for Elements, where unprefixed Element names use the default Namespace, if any.

If the parser is not doing Namespace processing, each attribute will have only a qName.

In all cases, the qName will be exactly what appears in the XML document.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095