Community articleaddNamespace method
Added by IBM contributorIBM on August 15, 2011
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 method adds a namespace declaration to the node it is called on. 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">


   public void addNamespace(
      String theURI,
      String thePrefix
   ) throws UWIException;


Table 1. Method parameters
theURIStringThe namespace URI. For example:

thePrefixStringThe prefix for the namespace. For example, xfdl.


Nothing or throws a generic exception (UWIException) if an error occurs.


The following method uses addNamespace 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".
   private static void addStatus(FormNodeP theNode) throws Exception
   XFDL theXFDL;
      /* Add the custom namespace to the form. */
      theNode.addNamespace("", "custom");
      /* Locate the global item in the global page so we can add a global
         option. */
      if (theNode = theNode.dereferenceEx(null, "", 0,
         UFL_ITEM_REFERENCE, null) == null)
         throw new UWIException("Could not locate node.");
      /* Get the XFDL object so we can create a new node. */
      if (theXFDL = (XFDL)IFXMan.lookupInterface(XFDL.XFDL_INTERFACE_NAME,
         XFDL.XFDL_CURRENT_VERSION, 0, null, null)) == null)
         throw new UWIException("Could not find XFDL interface.";
      /* 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 (theNode = theXFDL.create(theNode, UFL_APPEND_CHILD, null,
         "Processed", null, "custom:Status") == null)
         throw new UWIException("Could not create Status node.");

Parent topic:
FormNodeP class