Community articleUFLIsXFDL 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.



Description

This function determines whether a node belongs to the XFDL namespace.
Each namespace is defined in the form by a namespace declaration, as shown:
   xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.5" 
   xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"

Each namespace declaration defines both a prefix and a URI for the namespace. In this sample, the prefix for the XFDL namespace is xfdl and the URI is http://www.ibm.com/xmlns/prod/XFDL/7.5.
Tags within the form are assigned specific namespaces by using the defined prefix. For example, to declare that an option is in the custom namespace, use the prefix custom as shown:
   <field sid="testField">
      <custom:custom_option>value</custom:custom_option>
   </field>


Function

   r_error UFLIsXFDL(
      formNodeP theFormNode,
      r_boolean *theStatus
   );


Parameters

Table 1. Function parameters
ExpressionTypeDescription
theFormNodeformNodePThe node to check.
theStatusr_boolean*A pointer that will contain the node's status. OK indicates that it is in the XFDL namespace, NOTOK indicates that it is not.


Returns

OK on success or an error code on failure.

Example

The following function uses recursion to traverse the entire node structure and destroys all nodes that are not in the XFDL namespace. This function assumes that you are passing in the root node of the form.
   r_error deleteCustomInfo(formNodeP theNode)
   {
   r_boolean theStatus;
   formNodeP tempNode, tempNode2;
 
      /* Use recursion to step through each node in the form. */
 
      tempNode = UFLGetChildren(theNode);
      while(tempNode != null)
      {
         tempNode2 = UFLGetNext(tempNode);
         if (deleteCustomInfo(tempNode) != OK)
         {
            fprintf(stderr, "deleteCustomInfo returned an error.");
            return(NOTOK);
         }
         tempNode = tempNode2;
      }
 
      /* Determine whether the node is in the XFDL namespace. */
 
      if (UFLIsXFDL(theNode, &theStatus) != OK)
      {
         fprintf(stderr, "Could not determine if node is XFDL.");
         return(NOTOK);
      }
      /* If the node is not in the XFDL namespace, delete it. */
      if (*theStatus != OK)
      {
         if (   UFLDestroy(theNode) != OK)
         {
            fprintf(stderr, "Could not delete node.");
            return(NOTOK);
         }
      }
      return(OK);
   }


Parent topic:
FormNodeP functions