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

Description

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:
   xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.7" 
   xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"

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 http://www.ibm.com/xmlns/prod/XFDL/7.7. The prefix for the custom namespace is custom and the URI is http://www.ibm.com/xmlns/prod/XFDL/Custom.
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

   Sub AddNamespace(
      theURI As String, 
      thePrefix As String)


Parameters

Table 1. Function parameters
ExpressionTypeDescription
theURIStringThe namespace URI. For example:
http://www.ibm.com/xmlns/prod/XFDL/7.7

thePrefixStringThe prefix for the namespace. For example, xfdl.


Returns

Nothing or throws an exception if an error occurs.

Example

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"http://www.ibm.com/xmlns/prod/XFDL/Custom", "custom"
 
      ' Locate the global item in the global page
      Set TempNode = TempNode.DereferenceEx(vbNullString, "global.global", _
         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