version 1.20, 2001/07/03 18:25:45
|
version 1.27, 2002/02/20 23:14:19
|
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM |
// Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM, |
|
// The Open Group, Tivoli Systems |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// | // |
// Author: Mike Brasher (mbrasher@bmc.com) | // Author: Mike Brasher (mbrasher@bmc.com) |
// | // |
// Modified By: |
// Modified By: Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
|
// Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) |
|
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include "CIMClass.h" | #include "CIMClass.h" |
#include "CIMInstance.h" | #include "CIMInstance.h" |
#include "CIMObject.h" | #include "CIMObject.h" |
|
#include "CIMNamedInstance.h" |
|
#include "CIMParamValue.h" |
| |
|
PEGASUS_USING_STD; |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
static const Uint32 MESSAGE_SIZE = 128; | static const Uint32 MESSAGE_SIZE = 128; |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// testXmlDeclaration () |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::testXmlDeclaration ( |
|
XmlParser& parser, |
|
XmlEntry& entry) |
|
{ |
|
if (!parser.next (entry) || |
|
entry.type != XmlEntry::XML_DECLARATION || |
|
strcmp (entry.text, "xml") != 0) |
|
{ |
|
parser.putBack (entry); |
|
return false; |
|
} |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
// expectStartTag() | // expectStartTag() |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// getIsArrayAttribute() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getIsArrayAttribute( |
|
Uint32 lineNumber, |
|
const XmlEntry& entry, |
|
const char* tagName, |
|
Boolean& value) |
|
{ |
|
const char* tmp; |
|
|
|
if (!entry.getAttributeValue("ISARRAY", tmp)) |
|
return false; |
|
|
|
if (strcmp(tmp, "true") == 0) |
|
{ |
|
value = true; |
|
return true; |
|
} |
|
else if (strcmp(tmp, "false") == 0) |
|
{ |
|
value = false; |
|
return true; |
|
} |
|
|
|
char buffer[62]; |
|
sprintf(buffer, "Bad %s.%s attribute value", "ISARRAY", tagName); |
|
throw XmlSemanticError(lineNumber, buffer); |
|
return false; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// getCimNameAttribute() | // getCimNameAttribute() |
// | // |
// <!ENTITY % CIMName "NAME CDATA #REQUIRED"> | // <!ENTITY % CIMName "NAME CDATA #REQUIRED"> |
|
|
// | // |
// getCimTypeAttribute() | // getCimTypeAttribute() |
// | // |
|
// This method can be used to get a TYPE attribute or a PARAMTYPE attribute. |
|
// The only significant difference is that PARAMTYPE may specify a value of |
|
// "reference" type. This method recognizes these attributes by name, and |
|
// does not allow a "TYPE" attribute to be of "reference" type. |
|
// |
// <!ENTITY % CIMType "TYPE (boolean|string|char16|uint8|sint8|uint16 | // <!ENTITY % CIMType "TYPE (boolean|string|char16|uint8|sint8|uint16 |
// |sint16|uint32|sint32|uint64|sint64|datetime|real32|real64)"> | // |sint16|uint32|sint32|uint64|sint64|datetime|real32|real64)"> |
// | // |
|
// <!ENTITY % ParamType "PARAMTYPE (boolean|string|char16|uint8|sint8 |
|
// |uint16|sint16|uint32|sint32|uint64|sint64|datetime|real32|real64 |
|
// |reference)"> |
|
// |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
CIMType XmlReader::getCimTypeAttribute( | CIMType XmlReader::getCimTypeAttribute( |
Uint32 lineNumber, | Uint32 lineNumber, |
const XmlEntry& entry, | const XmlEntry& entry, |
const char* tagName) |
const char* tagName, |
|
const char* attributeName, |
|
Boolean required) |
{ | { |
const char* typeName; | const char* typeName; |
| |
if (!entry.getAttributeValue("TYPE", typeName)) |
if (!entry.getAttributeValue(attributeName, typeName)) |
|
{ |
|
if (required) |
{ | { |
char message[MESSAGE_SIZE]; | char message[MESSAGE_SIZE]; |
sprintf(message, "missing %s.TYPE attribute", tagName); |
sprintf(message, "missing %s.%s attribute", tagName, attributeName); |
throw XmlValidationError(lineNumber, message); | throw XmlValidationError(lineNumber, message); |
} | } |
|
else |
|
{ |
|
return CIMType::NONE; |
|
} |
|
} |
| |
CIMType type = CIMType::NONE; | CIMType type = CIMType::NONE; |
| |
|
|
else if (strcmp(typeName, "reference") == 0) | else if (strcmp(typeName, "reference") == 0) |
type = CIMType::REFERENCE; | type = CIMType::REFERENCE; |
| |
// ATTN: "reference" is not legal according to the DTD; however, it is |
if ((type == CIMType::NONE) || |
// used by the XML version of the CIM schema. |
((type == CIMType::REFERENCE) && |
|
(strcmp(attributeName, "PARAMTYPE") != 0))) |
if (type == CIMType::NONE) |
|
{ | { |
char message[MESSAGE_SIZE]; | char message[MESSAGE_SIZE]; |
sprintf(message, "Illegal value for %s.TYPE attribute", tagName); |
sprintf(message, "Illegal value for %s.%s attribute", tagName, |
|
attributeName); |
throw XmlSemanticError(lineNumber, message); | throw XmlSemanticError(lineNumber, message); |
} | } |
| |
|
|
XmlParser& parser, | XmlParser& parser, |
CIMValue& cimValue) | CIMValue& cimValue) |
{ | { |
//Test for Element value type |
//ATTN: Test for Element value type |
CIMType type = CIMType::STRING; | CIMType type = CIMType::STRING; |
| |
if (XmlReader::getValueElement(parser, type, cimValue)) | if (XmlReader::getValueElement(parser, type, cimValue)) |
|
|
return true; | return true; |
| |
// Test for Value.reference type | // Test for Value.reference type |
// ATTN:This returns a different type (CIMReference) |
|
// ATTN: Possibly change to simply return result after |
|
// we figure out the type differences. |
|
|
|
CIMReference reference; | CIMReference reference; |
if(XmlReader::getValueReferenceElement(parser, reference)) | if(XmlReader::getValueReferenceElement(parser, reference)) |
|
{ |
|
cimValue.set(reference); |
return true; | return true; |
|
} |
| |
return false; | return false; |
} | } |
|
|
// <!ATTLIST KEYVALUE | // <!ATTLIST KEYVALUE |
// VALUETYPE (string|boolean|numeric) 'string'> | // VALUETYPE (string|boolean|numeric) 'string'> |
// | // |
// ATTN-B: VALUE.REFERENCE ignored above; can't understand why it is needed! |
|
// |
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Boolean XmlReader::getKeyValueElement( | Boolean XmlReader::getKeyValueElement( |
|
|
// <!ATTLIST KEYBINDING | // <!ATTLIST KEYBINDING |
// %CIMName;> | // %CIMName;> |
// | // |
// ATTN-B: VALUE.REFERENCE ignored above; can't understand why it is needed! |
|
// |
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Boolean XmlReader::getKeyBindingElement( | Boolean XmlReader::getKeyBindingElement( |
|
|
name = getCimNameAttribute(parser.getLine(), entry, "KEYBINDING"); | name = getCimNameAttribute(parser.getLine(), entry, "KEYBINDING"); |
| |
if (!getKeyValueElement(parser, type, value)) | if (!getKeyValueElement(parser, type, value)) |
throw XmlValidationError(parser.getLine(), "Expected KEYVALUE element"); |
{ |
|
CIMReference reference; |
|
|
|
if (!getValueReferenceElement(parser, reference)) |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"Expected KEYVALUE or VALUE.REFERENCE element"); |
|
} |
|
|
|
type = KeyBinding::REFERENCE; |
|
value = reference.toString(); |
|
} |
| |
expectEndTag(parser, "KEYBINDING"); | expectEndTag(parser, "KEYBINDING"); |
return true; | return true; |
|
|
// <!ATTLIST INSTANCENAME | // <!ATTLIST INSTANCENAME |
// %ClassName;> | // %ClassName;> |
// | // |
// ATTN-B: VALUE.REFERENCE sub-element not accepted yet. |
// Note: An empty key name is used in the keyBinding when the INSTANCENAME is |
|
// specified using a KEYVALUE or a VALUE.REFERENCE. |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
|
|
| |
className = getClassNameAttribute(parser.getLine(), entry, "INSTANCENAME"); | className = getClassNameAttribute(parser.getLine(), entry, "INSTANCENAME"); |
| |
if (!empty) |
if (empty) |
{ | { |
|
return true; |
|
} |
|
|
String name; | String name; |
KeyBinding::Type type; | KeyBinding::Type type; |
String value; | String value; |
|
CIMReference reference; |
| |
|
if (getKeyValueElement(parser, type, value)) |
|
{ |
|
// Use empty key name because none was specified |
|
keyBindings.append(KeyBinding(name, value, type)); |
|
} |
|
else if (getValueReferenceElement(parser, reference)) |
|
{ |
|
// Use empty key name because none was specified |
|
type = KeyBinding::REFERENCE; |
|
value = reference.toString(); |
|
keyBindings.append(KeyBinding(name, value, type)); |
|
} |
|
else |
|
{ |
while (getKeyBindingElement(parser, name, value, type)) | while (getKeyBindingElement(parser, name, value, type)) |
keyBindings.append(KeyBinding(name, value, type)); | keyBindings.append(KeyBinding(name, value, type)); |
|
} |
| |
if (!empty) |
|
expectEndTag(parser, "INSTANCENAME"); | expectEndTag(parser, "INSTANCENAME"); |
} |
|
| |
return true; | return true; |
} | } |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// getParameterReferenceArrayElement() |
|
// |
|
// <!ELEMENT PARAMETER.REFARRAY (QUALIFIER*)> |
|
// <!ATTLIST PARAMETER.REFARRAY |
|
// %CIMName; |
|
// %ReferenceClass; |
|
// %ArraySize;> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getParameterReferenceArrayElement( |
|
XmlParser& parser, |
|
CIMParameter& parameter) |
|
{ |
|
XmlEntry entry; |
|
|
|
if (!testStartTagOrEmptyTag(parser, entry, "PARAMETER.REFARRAY")) |
|
return false; |
|
|
|
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
|
|
|
// Get PARAMETER.NAME attribute: |
|
|
|
String name = getCimNameAttribute( |
|
parser.getLine(), entry, "PARAMETER.REFARRAY"); |
|
|
|
// Get PARAMETER.REFERENCECLASS attribute: |
|
|
|
String referenceClass = getReferenceClassAttribute( |
|
parser.getLine(), entry, "PARAMETER.REFARRAY"); |
|
|
|
// Get PARAMETER.ARRAYSIZE attribute: |
|
|
|
Uint32 arraySize = 0; |
|
getArraySizeAttribute(parser.getLine(), entry, "PARAMETER.REFARRAY", |
|
arraySize); |
|
|
|
// Create parameter: |
|
|
|
parameter = CIMParameter(name, CIMType::REFERENCE, true, arraySize, |
|
referenceClass); |
|
|
|
if (!empty) |
|
{ |
|
getQualifierElements(parser, parameter); |
|
expectEndTag(parser, "PARAMETER.REFARRAY"); |
|
} |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
// GetParameterElements() | // GetParameterElements() |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
while (XmlReader::getParameterElement(parser, parameter) || | while (XmlReader::getParameterElement(parser, parameter) || |
XmlReader::getParameterArrayElement(parser, parameter) || | XmlReader::getParameterArrayElement(parser, parameter) || |
XmlReader::getParameterReferenceElement(parser, parameter)) |
XmlReader::getParameterReferenceElement(parser, parameter) || |
|
XmlReader::getParameterReferenceArrayElement(parser, parameter)) |
{ | { |
try | try |
{ | { |
|
|
| |
// Get ISARRAY attribute: | // Get ISARRAY attribute: |
| |
Boolean isArray = false; |
Boolean isArray = getCimBooleanAttribute( |
getIsArrayAttribute( |
parser.getLine(), entry, "QUALIFIER.DECLARATION", "ISARRAY", |
parser.getLine(), entry, "QUALIFIER.DECLARATION", isArray); |
false, false); |
| |
// Get ARRAYSIZE attribute: | // Get ARRAYSIZE attribute: |
| |
|
|
| |
if (!empty) | if (!empty) |
{ | { |
|
// ATTN-RK-P2-20020219: Decoding algorithm must not depend on the |
|
// ordering of qualifiers and parameters. |
getQualifierElements(parser, method); | getQualifierElements(parser, method); |
| |
GetParameterElements(parser, method); | GetParameterElements(parser, method); |
|
|
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
// getNamedInstanceElement() |
|
// |
|
// <!ELEMENT VALUE.NAMEDINSTANCE (INSTANCENAME,INSTANCE)> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getNamedInstanceElement( |
|
XmlParser& parser, |
|
CIMNamedInstance& namedInstance) |
|
{ |
|
XmlEntry entry; |
|
|
|
if (!testStartTag(parser, entry, "VALUE.NAMEDINSTANCE")) |
|
return false; |
|
|
|
CIMReference instanceName; |
|
|
|
// Get INSTANCENAME elements: |
|
|
|
if (!getInstanceNameElement(parser, instanceName)) |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"expected INSTANCENAME element"); |
|
} |
|
|
|
CIMInstance instance; |
|
|
|
// Get INSTANCE elements: |
|
|
|
if (!getInstanceElement(parser, instance)) |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"expected INSTANCE element"); |
|
} |
|
|
|
// Get VALUE.NAMEDINSTANCE end tag: |
|
|
|
expectEndTag(parser, "VALUE.NAMEDINSTANCE"); |
|
|
|
namedInstance.set(instanceName, instance); |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
// | // |
// getObject() | // getObject() |
// | // |
|
|
| |
expectContentOrCData(parser, entry); | expectContentOrCData(parser, entry); |
| |
if (strcmp(entry.text, "TRUE") == 0) |
if (CompareNoCase(entry.text, "TRUE") == 0) |
result = true; | result = true; |
else if (strcmp(entry.text, "FALSE") == 0) |
else if (CompareNoCase(entry.text, "FALSE") == 0) |
result = false; | result = false; |
else | else |
throw XmlSemanticError(parser.getLine(), | throw XmlSemanticError(parser.getLine(), |
|
|
| |
Boolean XmlReader::getErrorElement( | Boolean XmlReader::getErrorElement( |
XmlParser& parser, | XmlParser& parser, |
CIMException::Code& code, |
CIMStatusCode& code, |
const char*& description, | const char*& description, |
Boolean required) | Boolean required) |
{ | { |
|
|
throw XmlValidationError( | throw XmlValidationError( |
parser.getLine(), "missing ERROR.CODE attribute"); | parser.getLine(), "missing ERROR.CODE attribute"); |
| |
code = CIMException::Code(tmpCode); |
code = CIMStatusCode(tmpCode); |
| |
// Get ERROR.DESCRIPTION: | // Get ERROR.DESCRIPTION: |
| |
|
|
CIMReference& objectName) | CIMReference& objectName) |
{ | { |
String className; | String className; |
CIMReference instanceName; |
|
| |
if (getClassNameElement(parser, className, false)) | if (getClassNameElement(parser, className, false)) |
{ | { |
|
|
XmlParser& parser, | XmlParser& parser, |
CIMReference& objectPath) | CIMReference& objectPath) |
{ | { |
|
XmlEntry entry; |
|
|
|
if (!testStartTag(parser, entry, "OBJECTPATH")) |
|
return false; |
|
|
if (getClassPathElement(parser, objectPath)) | if (getClassPathElement(parser, objectPath)) |
|
{ |
|
expectEndTag(parser, "OBJECTPATH"); |
return true; | return true; |
|
} |
else if (getInstancePathElement(parser, objectPath)) | else if (getInstancePathElement(parser, objectPath)) |
|
{ |
|
expectEndTag(parser, "OBJECTPATH"); |
return true; | return true; |
|
} |
else | else |
{ | { |
throw XmlValidationError(parser.getLine(), | throw XmlValidationError(parser.getLine(), |
"expected INSTANCEPATH or CLASSPATH element"); | "expected INSTANCEPATH or CLASSPATH element"); |
} | } |
| |
|
PEGASUS_UNREACHABLE ( return false; ) |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// getEMethodCallStartTag() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getEMethodCallStartTag( |
|
XmlParser& parser, |
|
const char*& name) |
|
{ |
|
XmlEntry entry; |
|
|
|
if (!testStartTag(parser, entry, "EXPMETHODCALL")) |
|
return false; |
|
|
|
// Get EXPMETHODCALL.NAME attribute: |
|
|
|
if (!entry.getAttributeValue("NAME", name)) |
|
throw XmlValidationError(parser.getLine(), |
|
"Missing EXPMETHODCALL.NAME attribute"); |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// getEMethodResponseStartTag() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getEMethodResponseStartTag( |
|
XmlParser& parser, |
|
const char*& name) |
|
{ |
|
XmlEntry entry; |
|
|
|
if (!testStartTag(parser, entry, "EXPMETHODRESPONSE")) |
|
return false; |
|
|
|
// Get EXPMETHODRESPONSE.NAME attribute: |
|
|
|
if (!entry.getAttributeValue("NAME", name)) |
|
throw XmlValidationError(parser.getLine(), |
|
"Missing EXPMETHODRESPONSE.NAME attribute"); |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// getMethodCallStartTag() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getMethodCallStartTag( |
|
XmlParser& parser, |
|
const char*& name) |
|
{ |
|
XmlEntry entry; |
|
|
|
if (!testStartTag(parser, entry, "METHODCALL")) |
|
return false; |
|
|
|
// Get METHODCALL.NAME attribute: |
|
|
|
if (!entry.getAttributeValue("NAME", name)) |
|
throw XmlValidationError(parser.getLine(), |
|
"Missing METHODCALL.NAME attribute"); |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// getMethodResponseStartTag() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getMethodResponseStartTag( |
|
XmlParser& parser, |
|
const char*& name) |
|
{ |
|
XmlEntry entry; |
|
|
|
if (!testStartTag(parser, entry, "METHODRESPONSE")) |
return false; | return false; |
|
|
|
// Get METHODRESPONSE.NAME attribute: |
|
|
|
if (!entry.getAttributeValue("NAME", name)) |
|
throw XmlValidationError(parser.getLine(), |
|
"Missing METHODRESPONSE.NAME attribute"); |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// getParamValueElement() |
|
// |
|
// <!ELEMENT PARAMVALUE (VALUE|VALUE.REFERENCE|VALUE.ARRAY|VALUE.REFARRAY)?> |
|
// <!ATTLIST PARAMVALUE |
|
// %CIMName; |
|
// %ParamType;> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getParamValueElement( |
|
XmlParser& parser, |
|
CIMParamValue& paramValue) |
|
{ |
|
XmlEntry entry; |
|
const char* name; |
|
CIMType type; |
|
CIMValue value; |
|
|
|
if (!testStartTagOrEmptyTag(parser, entry, "PARAMVALUE")) |
|
return false; |
|
|
|
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
|
|
|
// Get PARAMVALUE.NAME attribute: |
|
|
|
if (!entry.getAttributeValue("NAME", name)) |
|
throw XmlValidationError(parser.getLine(), |
|
"Missing PARAMVALUE.NAME attribute"); |
|
|
|
// Get PARAMVALUE.PARAMTYPE attribute: |
|
|
|
type = getCimTypeAttribute(parser.getLine(), entry, "PARAMVALUE", |
|
"PARAMTYPE", false); |
|
|
|
if (!empty) |
|
{ |
|
// Parse VALUE.REFERENCE and VALUE.REFARRAY type |
|
if ( (type == CIMType::REFERENCE) || (type == CIMType::NONE) ) |
|
{ |
|
CIMReference reference; |
|
if (XmlReader::getValueReferenceElement(parser, reference)) |
|
{ |
|
value.set(reference); |
|
type = CIMType::REFERENCE; |
|
} |
|
// ATTN-RK-P2-20010219: This method does not exist. CIMValue does |
|
// not currently allow for an array of CIMReferences. |
|
//else if (XmlReader::getValueReferenceArrayElement(parser, value)) |
|
//{ |
|
// type = CIMType::REFERENCE; |
|
//} |
|
// If type==reference but no VALUE.REFERENCE found, use null value |
|
} |
|
|
|
// Parse non-reference value |
|
if ( type != CIMType::REFERENCE ) |
|
{ |
|
// If we don't know what type the value is, read it as a String |
|
CIMType effectiveType = type; |
|
if ( effectiveType == CIMType::NONE) |
|
{ |
|
effectiveType = CIMType::STRING; |
|
} |
|
|
|
if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) && |
|
!XmlReader::getValueElement(parser, effectiveType, value) ) |
|
{ |
|
value.clear(); // Isn't necessary; should already be cleared |
|
} |
|
} |
|
|
|
expectEndTag(parser, "PARAMVALUE"); |
|
} |
|
|
|
paramValue = CIMParamValue(CIMParameter(name, type), value); |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// getReturnValueElement() |
|
// |
|
// <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)> |
|
// <!ATTLIST RETURNVALUE |
|
// %ParamType;> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getReturnValueElement( |
|
XmlParser& parser, |
|
CIMValue& returnValue) |
|
{ |
|
XmlEntry entry; |
|
CIMType type; |
|
CIMValue value; |
|
|
|
if (!testStartTag(parser, entry, "RETURNVALUE")) |
|
return false; |
|
|
|
// Get RETURNVALUE.PARAMTYPE attribute: |
|
// NOTE: Array type return values are not allowed (2/20/02) |
|
|
|
type = getCimTypeAttribute(parser.getLine(), entry, "RETURNVALUE", |
|
"PARAMTYPE", false); |
|
|
|
// Parse VALUE.REFERENCE type |
|
if ( (type == CIMType::REFERENCE) || (type == CIMType::NONE) ) |
|
{ |
|
CIMReference reference; |
|
if (XmlReader::getValueReferenceElement(parser, reference)) |
|
{ |
|
returnValue.set(reference); |
|
type = CIMType::REFERENCE; |
|
} |
|
else if (type == CIMType::REFERENCE) |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"expected VALUE.REFERENCE element"); |
|
} |
|
} |
|
|
|
// Parse non-reference return value |
|
if ( type != CIMType::REFERENCE ) |
|
{ |
|
// If we don't know what type the value is, read it as a String |
|
if ( type == CIMType::NONE) |
|
{ |
|
type = CIMType::STRING; |
|
} |
|
|
|
if ( !XmlReader::getValueElement(parser, type, returnValue) ) |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"expected VALUE element"); |
|
} |
|
} |
|
|
|
expectEndTag(parser, "RETURNVALUE"); |
|
|
|
return true; |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |