Progress
Language Reference


CREATE-NODE-NAMESPACE( ) Method

Creates a namespace-aware XML node whose name can be an x:y combination rather than a single string.

NOTE: To ensure consistency across all nodes in an XML document, use either the CREATE-NODE-NAMESPACE( ) method or the CREATE-NODE( ) method to build an XML document; do not use both methods within a single document.

Return Type: LOGICAL

Applies To: X-document Object Handle

SYNTAX
CREATE-NODE-NAMESPACE( x-node-handle , namespace-uri , qualified-name , type ) 

x-node-handle

A valid X-NODEREF handle to use for the new namespace-aware XML node.

namespace-uri

A character expression representing the namespace Uniform Resource Identifier (URI). The namespace-uri must be unique and persistent. Although the namespace-uri may be an HTTP URL, there is no guarantee that it points to a retrievable resource. It is only a name and care should be taken if this name is used for other purposes.

qualified-name

A character expression representing the name of the node, optionally qualified with a prefix including a colon (for example, prefix:node-name). Unless you are using a default namespace, a prefix is required and should be set to the prefix specified when you declared the namespace using the xmlns attribute.

type

A character expression representing the node’s SUBTYPE, which will be either ELEMENT or ATTRIBUTE.

EXAMPLE

The following code fragment illustrates how to create a namespace-aware node in an XML document using either a specific namespace or the defalt namespace.

. . .
  /* Look for a colonized name in rootNodeName. */
  found = INDEX(rootNodeName, ":").
  IF found > 0 THEN
   DO:
    /* Namespace declarations are special kinds of attributes that */
    /* belong in the http://www.w3.org/2000/xmlns/ namespace.*/
    errStat = hDocument:CREATE-NODE-NAMESPACE(hNsDecl,
    "http://www.w3.org/2000/xmlns/", "xmlns:" + 
    SUBSTRING(rootNodeName, 1, found - 1), "attribute").
   END.
  ELSE
   DO:
    /* Use the default namespace, which does not need a */
    /* namespace declaration prefix, and assign it to the */
    /* http://www.w3.org/2000/xmlns/ namespace.*/
    errStat = hDocument:CREATE-NODE-NAMESPACE(hNsDecl,
    "http://www.w3.org/2000/xmlns/", "xmlns", "attribute").
   END.
  IF errStat = NO THEN
    LEAVE.

  /* Set the value of the namespace attribute to the namespace URI. */
  hNsDecl:NODE-VALUE = namespaceURI.
. . . 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095