cniElementNamespace
Use this function to get the value of the namespace attribute for the specified syntax element.
You must previously have set the syntax element name by using cniSetElementNamespace or cpiSetElementNamespace.
Use this function when you want to convert a message that belongs to a namespace-aware domain to a bit stream.
Syntax
CciSize cniElementNamespace(
int* returnCode,
CciElement* targetElement,
const CciChar* value,
CciSize length)
Parameters
returnCode
- The return code from the function (output). Specifying a NULL
pointer signifies that the node does not want to deal with errors.
If input is not NULL, the output signifies the success status of the
call. All exceptions thrown during the execution of this call are
re-thrown to the next upstream node in the flow. Call cciGetLastExceptionData for
details of the exception.Possible return codes are:
- CCI_SUCCESS
- CCI_EXCEPTION
- CCI_INV_ELEMENT_OBJECT
- CCI_INV_DATA_POINTER
- CCI_INV_DATA_BUFLEN
- CCI_INV_BUFFER_TOO_SMALL
targetElement
- Specifies the address of the target syntax element object (input).
value
- Specifies the address of a buffer into which the element namespace value is copied (output). A string of characters (including a NULL terminator) representing the namespace value is copied into this buffer. The buffer must be a portion of memory previously allocated by the caller.
length
- The length, in characters, of the buffer specified by the value parameter (input).
Return values
- If successful, the number of CciChars copied into the buffer is returned.
- If the buffer is not large enough to contain the attribute value, returnCode is set to CCI_BUFFER_TOO_SMALL, and the number of CciChars required is returned.
- If an exception occurs during execution, returnCode is set to CCI_EXCEPTION.
Example
if (element != 0) {
/*get name*/
cniElementName(&rc, element, (CciChar*)&elementName, sizeof(elementName));
/*get namespace*/
elementNamespace=(CciChar*)malloc(sizeof(CciChar) * elementNamespaceLength);
elementNamespaceLength = cniElementNamespace(&rc,
element,
elementNamespace,
elementNamespaceLength);
if (rc==CCI_BUFFER_TOO_SMALL){
free(elementNamespace);
elementNamespace=(CciChar*)malloc(sizeof(CciChar) * elementNamespaceLength);
elementNamespaceLength = cniElementNamespace(&rc,
element,
elementNamespace,
elementNamespaceLength);
}
checkRC(rc);