SetNamespace

Description

Sets the namespace for a PBDOM_ELEMENT object. If the namespace prefix and URI provided are empty strings, SetNamespace assigns no namespace to the PBDOM_ELEMENT object.

Syntax

pbdom_element_name.SetNamespace(string strNamespacePrefix, string strNamespaceUri, boolean bVerifyNamespace)

Argument

Description

pbdom_element_name

The name of a PBDOM_ELEMENT object

strNamespacePrefix

Prefix of the namespace to be set for the PBDOM_ELEMENT object

strNamespaceUri

URI of the namespace to be set for the PBDOM_ELEMENT object

bVerifyNamespace

A boolean value indicating whether verification should be performed to ensure that the provided namespace prefix and URI have been declared either within this PBDOM_ELEMENT object or in an ancestor PBDOM_ELEMENT object


Return value

Long.

Returns 0 for success and -1 if no in-scope namespace declaration matching the input prefix and URI exists.

Throws

EXCEPTION_INVALID_ARGUMENT -- If any of the input arguments is invalid, for example, null.

EXCEPTION_INVALID_NAME -- If the input namespace prefix or URI is invalid.

EXCEPTION_MEMORY_ALLOCATION_FAILURE -- If a memory allocation failure occurred during the execution of this method.

EXCEPTION_INTERNAL_XML_ENGINE_ERROR -- If an internal XML engine failure occurred during the execution of this method.

Usage

If bVerifyNamespace is set to true and the namespace prefix and URI have not been declared, SetNamespace returns a value of -1 and fails.

If bVerifyNamespace is set to false, SetNamespace sets the namespace of the PBDOM_ELEMENT object to the specified prefix and URI. It is the responsibility of the PBDOM user to ensure that such a namespace is declared and is in scope for this PBDOM_ELEMENT object before the document is saved and converted to an XML document.

See also

AddNamespaceDeclaration

GetNamespacePrefix

GetNamespaceUri

GetQualifiedName

RemoveNamespaceDeclaration