Community articleAddNamespace function
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 function 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">


   Sub AddNamespace(
      theURI As String, 
      thePrefix As String)


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

thePrefixStringThe prefix for the namespace. For example, xfdl.


Nothing or throws an exception if an error occurs.


The following function adds a custom namespace to a form and then adds a custom option to the global item. First, the function uses AddNamespace to add the custom namespace to the form. It then uses DereferenceEx to locate the global item on the form's global page. Finally, it uses Create to add a custom option to the global item.
   Sub AddCustomNamespace(Node)
      Dim TempNode, XFDL  ' objects
      Set TempNode = Node
      ' Add the Custom namespace to the form
      TempNode.AddNamespace"", "custom"
      ' Locate the global item in the global page
      Set TempNode = TempNode.DereferenceEx(vbNullString, "", _
         0, UFL_ITEM_REFERENCE, Nothing)
      ' Create an XFDL object so that we can use the create function
      Set XFDL = CreateObject("IBM_Forms.xfdl_XFDL")
      ' Create a "status" option in the custom namespace as a child of the
      ' global item.
      Set TempNode = XFDL.Create(TempNode, UFL_APPEND_CHILD, vbNullString, _
         "Processed" , vbNullString, "custom:status")
   End Sub

Parent topic:
FormNodeP functions