IWSDXMLContext::AddNamespace method (wsdxml.h)

Creates an object that represents a namespace in an XML context. If the namespace already exists, no new namespace will be added, and the namespace object for the existing name will be returned.

Syntax

HRESULT AddNamespace(
  [in]  LPCWSTR          pszUri,
  [in]  LPCWSTR          pszSuggestedPrefix,
  [out] WSDXML_NAMESPACE **ppNamespace
);

Parameters

[in] pszUri

The URI of the namespace.

[in] pszSuggestedPrefix

The namespace prefix to use when generating XML. If the namespace already exists, pszSuggestedPrefix will overwrite the prefix currently associated with the namespace. The XML context may assign a different namespace prefix. The prefix assigned by the XML context takes precedence over the suggested prefix. The PreferredPrefix member of the structure pointed to by ppNamespace contains the prefix assigned by the XML context.

[out] ppNamespace

Pointer to the address of the WSDXML_NAMESPACE structure that represents the namespace. You must deallocate ppNamespace by calling WSDFreeLinkedMemory. This parameter is optional.

Return value

Possible return values include, but are not limited to, the following.

Return code Description
S_OK
The method succeeded.
E_INVALIDARG
pszUri is NULL, the length in characters of the URI string exceeds WSD_MAX_TEXT_LENGTH (8192), pszSuggestedPrefix is NULL, or the length in characters of the prefix string exceeds WSD_MAX_TEXT_LENGTH (8192).
E_OUTOFMEMORY
Insufficient memory to complete the operation.
E_FAIL
The method failed.

Remarks

The returned WSDXML_NAMESPACE structure can be used to force an association between the namespace prefix (as specified by pszSuggestedPrefix) and the namespace URI (as specified by pszUri). Once this association is established, the XML generator will produce XML with the specified namespace prefix.

You can call AddNamespace to retrieve the WSDXML_NAMESPACE structure created when a namespace was automatically generated by a call to AddNameToNamespace.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header wsdxml.h (include Wsdapi.h)
DLL Wsdapi.dll

See also

IWSDXMLContext