Create a SAX-attributes object
- Last Updated: June 3, 2021
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
Use the CREATE SAX-ATTRIBUTES
statement to create an instance of a SAX-attributes object and assign its handle to
the handle variable specified.
Syntax
|
- handle
- Variable of type
HANDLEwhich stores the handle of the new SAX-attributes object. - IN WIDGET-POOL pool-name
- Specifies the widget pool where the AVM creates the new object. If you do not specify a widget pool, the AVM creates the object in the current default widget pool.
- NO-ERROR
- Specifies that the AVM should suppress errors occurring
during the creation of the SAX-attributes handle. After the
CREATE SAX-ATTRIBUTESstatement completes, you can check theERROR-STATUSsystem handle for information about errors that might have occurred.
In ABL, a SAX-attributes object can be automatically created and
managed by the SAX parser, or programatically created and managed by you. Automatic
SAX-attributes objects are created, populated, and destroyed during the scope of
the StartElement callback procedure or method.
The StartElement callback is called by the
SAX-reader object each time the SAX parser encounters a new XML element during a
read operation. The SAX parser populates the SAX-attributes object, but you may
interact with the object during the scope of the StartElement callback procedure or method. For example, you
may add elements, update elements, and remove elements from the SAX-attributes
object.
At the conclusion of the callback, the SAX-attributes object is
deleted and your access to the element list is lost. To save the XML attributes list, you
would need to create another SAX-attributes object that is not tied to the scope
of the StartElement callback procedure or
method. Then, from within the StartElement
callback, you would use the COPY-SAX-ATTRIBUTES( )
method on the new object and provide the handle to the automatically created
SAX-attributes object, which is the attributes
input parameter of the StartElement callback.
Finally, you would likely pass the XML element and its attributes to another
procedure outside of the callback's scope for further processing.
The SAX-writer also supports use of the SAX-attributes object. Here, you could pass it a copy of an attribute list from an XML element, or you might define a SAX-attributes object that contains a standard set of attribute values to apply to particular XML elements output by the SAX-writer object.
For an example of using a user-created SAX-attributes object, see Write XML Documents with the Simple API for XML (SAX).