All Frameworks  Class Hierarchy  This Framework  Previous  Next  Indexes

XMLParser Interface CATISAXAttributeList

System.IUnknown
  |
  +---System.IDispatch
    |
    +---System.CATBaseUnknown
      |
      +---CATISAXAttributeList
 

Usage: an implementation of this interface is supplied and you must use it as is. You should not reimplement it.


interface CATISAXAttributeList

Interface for an element's attribute specifications.
The SAX parser implements this interface and passes an instance to the SAX application as the second argument of each CATISAXDocumentHandler.StartElement event. The instance provided will return valid results only during the scope of the CATISAXDocumentHandler.StartElement invocation (to save it for future use, the application must make a copy). A CATISAXAttributeList.DocumentHandler.StartElement invocation (to save it for future use, the application must make a copy). A includes only attributes that have been specified or defaulted: #IMPLIED attributes will not be included. There are two ways for the SAX application to obtain information from the CATISAXAttributeList. First, it can iterate through the entire list:

 HRESULT StartElement(const CATUnicodeString & iName, const CATISAXAttributeList_var& iAttributes) {
     HRESULT hr = S_OK;
     if (iAttributes != NULL_var) {
         unsigned int length = 0;
         hr = iAttributes->GetLength(length);
         if (SUCCEEDED(hr)) {
             for (unsigned int i = 0; i < length; i++) {
                 CATUnicodeString name;
                 hr = iAttributes->GetName(i, name);
                 if (FAILED(hr)) {
                     break;
                 }
                 CATUnicodeString type;
                 hr = iAttributes->GetType(i, type);
                 if (FAILED(hr)) {
                     break;
                 }
                 CATUnicodeString value;
                 hr = iAttributes->GetValue(i, value);
                 if (FAILED(hr)) {
                     break;
                 }
                [...]
             }
         }
     }
     return hr;
 }
 
(Note that the result of GetLength will be zero if there are no attributes.) As an alternative, the application can request the value or type of specific attributes:
 HRESULT StartElement(const CATUnicodeString & iName, const CATISAXAttributeList_var& iAttributes) {
     HRESULT hr = E_FAIL;
     if (iAttributes != NULL_var) {
         CATUnicodeString identifier;
         hr = iAttributes->GetValue("id", identifier);
         if (FAILED(hr)) {
             return hr;
         }
         CATUnicodeString label;
         hr = iAttributes->GetValue("label", label);
         if (FAILED(hr)) {
             return hr;
         }
         [...]
     }
     return hr;
 }
 
See also:
CATISAXDocumentHandler.StartElement


Method Index


o GetLength(unsigned int&)
Retrieves the number of attributes in this list.
o GetName(unsigned int,CATUnicodeString&)
Retrieves the name of an attribute in this list (by position).
o GetType(CATUnicodeString&,CATUnicodeString&)
Retrieves the type of an attribute in the list (by name).
o GetType(unsigned int,CATUnicodeString&)
Retrieves the type of an attribute in the list (by position).
o GetValue(CATUnicodeString&,CATUnicodeString&)
Retrieves the value of an attribute in the list (by name).
o GetValue(unsigned int,CATUnicodeString&)
Retrieves the value of an attribute in the list (by position).

Methods


o GetLength
public virtual HRESULT GetLength(unsigned int& oLength) = 0
Retrieves the number of attributes in this list. The SAX parser may provide attributes in any arbitrary order, regardless of the order in which they were declared or specified. The number of attributes may be zero.
Parameters:
oLength
The number of attributes in the list.
o GetName
public virtual HRESULT GetName( const unsigned int iPosition,
CATUnicodeString& oName) = 0
Retrieves the name of an attribute in this list (by position). The names must be unique: the SAX parser shall not include the same attribute twice. Attributes without values (those declared #IMPLIED without a value specified in the start tag) will be omitted from the list. If the attribute name has a namespace prefix, the prefix will still be attached.
Parameters:
iPosition
The index of the attribute in the list (starting at 0).
oName
The name of the indexed attribute.
Returns:
The method returns E_FAIL if the index is out of range, S_OK otherwise.
See also:
GetLength
o GetType
public virtual HRESULT GetType( const CATUnicodeString& iName,
CATUnicodeString& oType) = 0
Retrieves the type of an attribute in the list (by name). The return value is the same as the return value for GetType. If the attribute name has a namespace prefix in the document, the application must include the prefix here.
Parameters:
iName
The name of the attribute.
oType
The attribute type as a string.
Returns:
The method returns E_FAIL if no such attribute exists, S_OK otherwise.
See also:
GetType
o GetType
public virtual HRESULT GetType( const unsigned int iPosition,
CATUnicodeString& oType) = 0
Retrieves the type of an attribute in the list (by position). The attribute type is one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper case). If the parser has not read a declaration for the attribute, or if the parser does not report attribute types, then it must return the value "CDATA" as stated in the XML 1.0 Recommentation (clause 3.3.3, "Attribute-Value Normalization"). For an enumerated attribute that is not a notation, the parser will report the type as "NMTOKEN".
Parameters:
iPosition
The index of the attribute in the list (starting at 0).
oType
The attribute type as a string.
Returns:
The method returns E_FAIL if the index is out of range, S_OK otherwise.
See also:
GetLength, GetType
o GetValue
public virtual HRESULT GetValue( const CATUnicodeString& iName,
CATUnicodeString& oValue) = 0
Retrieves the value of an attribute in the list (by name). The return value is the same as the return value for GetValue. If the attribute name has a namespace prefix in the document, the application must include the prefix here.
Parameters:
iName
The name of the attribute in the list.
oValue
The attribute value as a string, or null if no such attribute exists.
Returns:
The method returns E_FAIL if no such attribute exists, S_OK otherwise.
See also:
GetValue
o GetValue
public virtual HRESULT GetValue( const unsigned int iPosition,
CATUnicodeString& oValue) = 0
Retrieves the value of an attribute in the list (by position). If the attribute value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens will be concatenated into a single string separated by whitespace.
Parameters:
iPosition
The index of the attribute in the list (starting at 0).
oValue
The attribute value as a string
Returns:
The method returns E_FAIL if the index is out of range, S_OK otherwise.
See also:
GetLength, GetValue

This object is included in the file: CATISAXAttributeList.h
If needed, your Imakefile.mk should include the module: CATXMLParserItf

Copyright © 2003, Dassault Systèmes. All rights reserved.