Community articleGetPrefix 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 returns the namespace prefix for the node.
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>


Note: A given prefix may not always resolve to the same namespace. Different portions of the form may define the prefix differently. For example, the custom prefix may resolve to a different namespace on the first page of a form than it does on the following pages.

Function

   Function GetPrefix() As String


Parameters

There are no parameters for this function.

Returns

The prefix for the node's namespace or throws an exception if an error occurs.

Example

The following function removes all nodes from the form that have a namespace prefix of "custom". The function walks through the form using GetChildren and GetNext in a recursive loop. While walking the form, it uses GetPrefix to locate nodes in the custom namespace and deletes them using Destroy. This function assumes that you are passing it the root node of the form.
   Sub DeleteCustomPrefix(Node)
 
      Dim TempNode, TempNode2  ' IFormNodeP
 
      ' Use recursion to step through each node of the form.
 
      Set TempNode = Node.GetChildren
 
      Do While (Not(TempNode is Nothing))
         Set TempNode2 = TempNode.GetNext
         DeleteCustomPrefix(TempNode)
         Set TempNode = TempNode2
      Loop
 
      ' If the node has a namespace prefix of "custom", delete it.
 
      If (Node.GetPrefix = "custom") Then
         Node.Destroy
      End If
 
   End Sub


Parent topic:
FormNodeP functions