Community articleUFLGetLocalName function
Added by IBM contributorIBM on July 26, 2013
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars


This function returns the local name of a given node. The local name is determined by the XML tag that represents that node. For example, examine the following XML fragment:
   <page sid="PAGE1">
      <global sid="global"></global>
      <field sid="testField">
         <bgcolor>120, 120, 120</bgcolor>

In this sample, the name of the page node is "page", the name of the field node is "field", the name of the value node is "value", and the name of the bgcolor node is "bgcolor".
Note that the local name does not include any namespace prefix that might exist. For example, you might have a custom option in a different namespace as shown:
   <field sid="testField">

In this case, the local name of the custom option is returned without the prefix, resulting in "my_option".


   r_error UFLGetLocalName( 
      formNodeP theNode,
      r_charP *localName


Table 1. Function parameters
theNodeformNodePThe form node.
localNamer_charP*A pointer to the local name of the node.


OK on success or an error code on failure.


The following function takes the root node of the form and uses recursion to step through each node in the form. The function uses UFLIsXFDL and UFLGetLocalName to locate all label nodes in the XFDL namespace and changes the background color of those nodes to green.
   r_error changeLabelColor(formNodeP theNode)
   formNodeP tempnode, bgcolorNode;
   r_boolean XFDLNode;
   r_charP localName;
   r_error error;
      /* Use recursion to step through each node in the form. */
      if ((tempNode = UFLGetChildren(theNode)) == NULL)
         fprintf(stderr, "Could not locate child node.\n");
      while(tempNode != NULL)
         if ((error = changeLabelColor(tempNode)) != OK)
            fprintf(stderr, "Could not call changeLabelColor.\n");
      /* Check to see if the node is in the XFDL namespace. */
      if ((error = UFLIsXFDL(theNode, &XFDLNode)) != OK)
         fprintf(stderr, "Could not determine whether node is in XFDL
      /* Get the local name of the node. */
      if ((error = UFLGetLocalName(theNode, &localName)) != OK)
         fprintf(stderr, "Could not get local name of node.\n");
      /* If the node is a label in the XFDL namespace, set the bgcolor
         option to "green". */
      if ((XFDLNode == OK) && (cp_strcmp(localName, "label") == OK))
         if ((error = UFLSetLiteralByRefEx(theNode, NULL, "bgcolor[0]", 0,
            NULL, NULL, "green")) != OK)
            fprintf(stderr, "Could not set node color to green.\n");
      /* Free memory. */

Parent topic:
FormNodeP functions