Community articleUFLGetAttributeList function
Added by IBM contributorIBM on May 2, 2012
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.


This function returns a list of attributes and a list of corresponding namespaces for a given node. For example, the following XFDL represents a mimedata node:
<mimedata encoding="base64"></mimedata>

In this sample, getAttributeList will return a list of attributes that contains encoding and a list of namespaces that contains


   r_error UFLGetAttributeList(
      formNodeP theNode,
      r_charP **theNamespaceList,
      r_long *theNamespaceListSize,
      r_charP **theAttributeList,
      r_long *theAttributeListSize


Table 1. Function parameters
theNodeformNodePThe form node containing the attributes.
theNamespaceListr_charP**A pointer that contains a list of namespace URIs. For example:

Each URI corresponds to the attribute in the same position in the attribute list.
theNameSpaceListSize r_long*A pointer that contains the number of entries in the namespace list.
theAttributeListr_charP**A pointer that contains a list of attributes. For example, compute, encoding, and so on. Each attribute corresponds to a URI in the same position in the namespace list.
theAttributeListSizer_long*A pointer that contains the number of entries in the attribute list.


OK on success or an error code on failure.


The following function uses UFLGetAttributeList to retrieve the list of a node's attributes. It then searches through the list looking for a compute attribute. When it locates a compute attribute, it uses UFLRemoveAttribute to remove the compute from the node.
   r_error stripComputes(formNodeP theNode)
   r_long counter;
   r_charP *theNamespaces;
   r_long theNamespaceCount;
   r_charP *theAttributes;
   r_long theAttributeCount;
   r_error error;
      /* Retrieve the list of attributes for the supplied node. */   
      if ((error = UFLGetAttributeList(theNode, &theNamespaces,
         &theNamespaceCount, &theAttributes, &theAttributeCount)) != OK)
         fprintf(stderr, "Could not retrieve attribute list.\n");
      /* Step through the list searching for the compute attribute. If the
         compute attributes is found, delete it. */
      for (counter = 0; counter < theAttributeCount; counter++)
         if (cp_strcmp(theAttributes [counter], "compute") == OK)
            if ((error = UFLRemoveAttribute(theNode,
               theNamespaces [counter], theAttributes [counter])) != OK)
               fprintf(stderr, "Could not remove attribute.\n");
      /* Free memory. */
      for (counter = 0; counter < theAttributeCount; counter++)
         cp_free(theNamespaces [counter]);
         cp_free(theAttributes [counter]);

Parent topic:
FormNodeP functions