Back to Contents


The SaxAttributes class

Summary:

See also: Built-in Classes, XML Utils


Basics

Purpose:

The SaxAttributes class provides methods to manipulate XML element attributes.

Syntax:

om.SaxAttributes

Methods:

Class Methods
Name Description
copy( src SaxAttributes )
 
RETURNING om.SaxAttributes
Clones an existing SaxAttributes object.
create( )
 
RETURNING om.SaxAttributes
Creates a new, empty SaxAttributes object.
Object Methods
Name Description
addAttribute( n STRING, v STRING ) Adds an attribute to the end of the list.
clear( ) Clears the attribute list.
getLength( )
 
RETURNING INTEGER
Returns the number of attributes in the list.
getName( pos INTEGER )
 
RETURNING STRING
Returns the name of the attribute at position pos.
getValue( att STRING )
 
RETURNING STRING
Returns the value of the attribute identified by the name att.
getValuebyIndex( pos INTEGER )
 
RETURNING STRING
Returns the value of the attribute at position pos.
removeAttribute( pos INTEGER )
 
RETURNING INTEGER
Removes the attribute at position pos.
setAttributes( atts om.SaxAttributes ) Clears the current attribute list and adds all attributes of atts

Usage:

This class provides basic methods to manipulate attributes of an XML element. To process element attributes, a SaxAttributes object can be used in cooperation with an XmlReader object. You get an instance of SaxAttributes with the XmlReader.getAttributes() method.

Examples

Example 1:

01 FUNCTION displayAttributes( a )
02    DEFINE a om.SaxAttributes
03    DEFINE i INTEGER
04    FOR i=1 to a.getLength()
05       DISPLAY a.getName(i) || "=[" || a.getValueByIndex(i) || "]"
06    END FOR
07 END FUNCTION