Progress
External Program
Interfaces
SAX-ATTRIBUTES Object
When the parser encounters an XML Start-Tag that has one or more attributes, such as:
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 .
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:
- You can traverse the list, getting each attribute’s data in turn by using the GET-XXX-BY-INDEX methods.
- You can use an attribute’s name to get its data.
This approach has variations, depending on whether you are using Namespace processing or not. For more information on this point, see the "Namespace Processing" section of this chapter.)
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.
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 |