Community articleGetPrefixFromNamespaceURI 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 returns the namespace prefix for a specific namespace URI.You can call this function from any node in the form, as long as that node either declares or inherits the namespace in question.
Each namespace is defined in the form by a namespace declaration, as shown:

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
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">


   Function GetPrefixFromNamespaceURI(
      theURI As String
      ) As String


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


The namespace prefix or throws an exception if an error occurs. If the namespace URI is not declared, the result is null.


The following function adds some custom user information to the form, but assumes that the prefix used for the custom namespace is unknown. The function first uses GetPrefixFromNamespaceURI to determine which prefix is used for the custom namespace. It then concatenates that prefix with the tag ":User" to create the name for a new node. Next, it uses DereferenceEx to locate the global item in the global page. Finally, it uses Create to add a custom option called "User" to the form.
   Sub AddUserInfo(Form, UserName)
      Dim XFDL, TempNode  ' objects
      Dim ThePrefix, NewName  ' Strings
      Set TempNode = Form
      ' Retrieve the prefix for the custom namespace
      ThePrefix = TempNode.GetPrefixFromNamespaceURI( _
      ' Create a name for a new node by concatenating the prefix with ":User"
      NewName = ThePrefix & ":User"
      ' Locate the global item in the global page so we can add a global
      ' option
      Set TempNode = TempNode.DereferenceEx(vbNullString, "", _
         0, UFL_ITEM_REFERENCE, Nothing)
      ' Create an XFDL object so we can use the create function
      Set XFDL = CreateObject("PureEdge.xfdl_XFDL")
      ' Create new node in the custom namespace that represents the user of
      ' the form and give it a value of "TJones"
      Set TempNode = XFDL.Create(TempNode, UFL_APPEND_CHILD, vbNullString, _
         UserName , vbNullString, NewName)
   End Sub

Parent topic:
FormNodeP functions