Community articleUFLAddNamespace 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 adds a namespace declaration to the node it is passed. Each namespace is defined in the form using the XML xmlns namespace declaration as shown in these two sample declarations:

Each namespace declaration defines a prefix and a URI for the namespace. In the samples shown, the prefix for the XFDL namespace is xfdl and the URI is The prefix for the custom namespace is custom and the URI is
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">


   r_error UFLAddNamespace(
      formNodeP theNode,
      r_charP theURI,
      r_charP thePrefix


Table 1. Function parameters
theNode formNodePAny node in the form.
theURIr_charPThe namespace URI. For example:

thePrefixr_charPThe prefix for the namespace. For example, xfdl.


OK on success or an error code on failure.


The following function uses UFLAddNamespace to add a custom namespace to a form. It then locates the global item in the global page and adds a custom option to that item which marks the status of the form as "Processed".
   r_error addStatus(formNodeP theForm)
   XFDL theXFDL;
   formNodeP tempNode;
   r_error error;
      /* Add the custom namespace to the form. */
      if ((error = UFLAddNamespace(theForm, 
         "", "custom")) != OK)
         fprintf(stderr, "Could not create custom namespace.\n");
      /* Locate the global item in the global page so we can add a global
         option. */
      if ((tempNode = UFLDereferenceEx(theForm, NULL, "", 0,
         fprintf(stderr, "Could not locate global item node.\n");
      /* Create a new option node as a child of the global item.  This node
         is created in the custom namespace, called "Status", and given a
         value of "Processed". */
      if ((tempNode = UFLCreate(tempNode, UFL_APPEND_CHILD, NULL,
         "Processed", NULL, "custom:Status") == NULL)
         fprintf(stderr, "Could not create option node.\n");

Parent topic:
FormNodeP functions