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 : Retrieving data from a SAX-attributes object
 
Retrieving data from a SAX-attributes object
To get information about each attribute from a SAX-attributes object, use the GET-xxx methods. These methods let your application get the SAX-attributes data in 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
Note: This approach has variations, depending on whether you are using namespace processing or not. For more information on this point, see Namespace processing.
There are six facts you can get about each attribute, although three are variations on the attribute name. Each GET-xxx method retrieves one fact. The following table describes the six facts and the function of the GET-xxx methods.
Table 9. 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 local name, if namespace processing is available
GET-LOCALNAME-BY-INDEX( )
Its Qualified name (qName)
GET-QNAME-BY-INDEX( )
Its XML attribute type (declared in the DTD or XML Schema)
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 processing namespaces—that is, if SAX-reader object 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 the 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 one exists. The attribute is not associated with any namespace. Contrast this case with the case for unprefixed elements. Unprefixed elements do use the default namespace, if one exists.
If the parser is not processing namespaces, each attribute will only have a qName. In all cases, the qName will be exactly what appears in the XML document.