OpenEdge Development: Working with XML - Product ...
OpenEdge Development: Working with XML - Product ...
OpenEdge Development: Working with XML - Product ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Reading <strong>XML</strong> Documents <strong>with</strong> the Simple API for <strong>XML</strong> (SAX)<br />
3–6<br />
SAX-attributes object<br />
When the parser encounters the start tag of a new <strong>XML</strong> element, it knows to call the<br />
startElement callback procedure. At this time, the parser creates a SAX-attributes object and<br />
passes it to the startElement callback as an input parameter. Thus, when you define your<br />
startElement callback, you define the name of the parameter that holds the handle to this<br />
automatically created object and this is how your callback can access the attributes of the <strong>XML</strong><br />
element.<br />
For example, suppose the parser encounters an <strong>XML</strong> start tag that has one or more attributes,<br />
such as:<br />
<br />
The parser creates and populates the StartElement callback attributes parameter <strong>with</strong><br />
information on the <strong>XML</strong> element’s attributes. In the example, name and id are attributes. The<br />
attributes parameter is a handle to a SAX-attributes object.<br />
Note: The SAX-attributes object is similar to the Attributes interface of the Java Sax2 API.<br />
For most basic use cases, you will be working <strong>with</strong> this automatically created SAX-attributes<br />
object. For information on programmatically creating your own SAX-attributes object, see the<br />
“Creating a SAX-attributes object” section on page 3–9.<br />
Table 3–3 summarizes the attributes and methods of the SAX-attributes object. For complete<br />
reference entries, see <strong>OpenEdge</strong> <strong>Development</strong>: ABL Reference.<br />
Table 3–3: SAX-attributes attribute and method summary (1 of 2)<br />
This attribute or method . . . Lets you . . .<br />
NUM-ITEMS attribute See how many attributes the <strong>XML</strong> element<br />
has<br />
GET-INDEX-BY-NAMESPACE-NAME( ) method<br />
GET-INDEX-BY-QNAME( ) method<br />
GET-LOCALNAME-BY-INDEX( ) method<br />
GET-QNAME-BY-INDEX( ) method<br />
GET-URI-BY-INDEX( ) method<br />
GET-TYPE-BY-INDEX( ) method<br />
GET-TYPE-BY-NAMESPACE-NAME( ) method<br />
GET-TYPE-BY-QNAME( ) method<br />
GET-VALUE-BY-INDEX( ) method<br />
GET-VALUE-BY-NAMESPACE-NAME( ) method<br />
GET-VALUE-BY-QNAME( ) method<br />
Get where on the attribute list a particular<br />
attribute resides<br />
Get the name of a particular attribute<br />
Get the type of a particular attribute<br />
Get the value of a particular attribute