version 1.88, 2003/08/25 15:15:02
|
version 1.94.4.1, 2004/03/31 00:23:20
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2003//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
// | // |
// 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 |
|
|
// (carolann_graves@hp.com) | // (carolann_graves@hp.com) |
// Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) | // Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) |
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) | // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
|
#include "CIMObject.h" | #include "CIMObject.h" |
#include "CIMParamValue.h" | #include "CIMParamValue.h" |
#include "System.h" | #include "System.h" |
|
#include "XmlConstants.h" |
#ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM | #ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM |
#include "OS400ConvertChar.h" | #include "OS400ConvertChar.h" |
#endif | #endif |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// testStartTagOrEmptyTag() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::testStartTagOrEmptyTag( |
|
XmlParser& parser, |
|
XmlEntry& entry) |
|
{ |
|
if (!parser.next(entry) || |
|
(entry.type != XmlEntry::START_TAG && |
|
entry.type != XmlEntry::EMPTY_TAG)) |
|
{ |
|
parser.putBack(entry); |
|
return false; |
|
} |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
// testContentOrCData() | // testContentOrCData() |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
return true; | return true; |
} | } |
| |
inline Uint8 _hexCharToNumeric(const char c) |
inline Uint8 _xmlReader_hexCharToNumeric(const char c) |
{ | { |
Uint8 n; | Uint8 n; |
| |
|
|
| |
} | } |
| |
Uint8 digit1 = _hexCharToNumeric(char(uriString[++i])); |
Uint8 digit1 = _xmlReader_hexCharToNumeric(char(uriString[++i])); |
Uint8 digit2 = _hexCharToNumeric(char(uriString[++i])); |
Uint8 digit2 = _xmlReader_hexCharToNumeric(char(uriString[++i])); |
if ( (digit1 > 15) || (digit2 > 15) ) | if ( (digit1 > 15) || (digit2 > 15) ) |
{ | { |
// l10n | // l10n |
|
|
x = x << 4; | x = x << 4; |
| |
// Make sure we don't overflow when we add the next digit | // Make sure we don't overflow when we add the next digit |
Sint64 newDigit = Sint64(_hexCharToNumeric(*p++)); |
Sint64 newDigit = Sint64(_xmlReader_hexCharToNumeric(*p++)); |
if (PEGASUS_SINT64_MIN - x > -newDigit) | if (PEGASUS_SINT64_MIN - x > -newDigit) |
{ | { |
return false; | return false; |
|
|
x = x << 4; | x = x << 4; |
| |
// We can't overflow when we add the next digit | // We can't overflow when we add the next digit |
Uint64 newDigit = Uint64(_hexCharToNumeric(*p++)); |
Uint64 newDigit = Uint64(_xmlReader_hexCharToNumeric(*p++)); |
if (PEGASUS_UINT64_MAX - x < newDigit) | if (PEGASUS_UINT64_MAX - x < newDigit) |
{ | { |
return false; | return false; |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// skipElement() |
|
// |
|
//------------------------------------------------------------------------------ |
|
void XmlReader::skipElement( |
|
XmlParser& parser, |
|
XmlEntry& entry) |
|
{ |
|
const char * tag_name = entry.text; |
|
|
|
if (entry.type == XmlEntry::EMPTY_TAG) |
|
{ |
|
return; |
|
} |
|
|
|
while (testStartTagOrEmptyTag(parser, entry)) |
|
{ |
|
skipElement(parser, entry); |
|
} |
|
|
|
if (testContentOrCData(parser, entry)) |
|
{ |
|
; // skip |
|
} |
|
|
|
expectEndTag(parser, tag_name); |
|
return; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
// getValueElement() | // getValueElement() |
// | // |
// <!ELEMENT VALUE (#PCDATA)> | // <!ELEMENT VALUE (#PCDATA)> |
|
|
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
if (!testStartTag(parser, entry, "INSTANCE")) |
if (!testStartTagOrEmptyTag(parser, entry, "INSTANCE")) |
return false; | return false; |
| |
|
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
|
|
String className = getClassNameAttribute( | String className = getClassNameAttribute( |
parser.getLine(), entry, "INSTANCE"); | parser.getLine(), entry, "INSTANCE"); |
| |
cimInstance = CIMInstance(className); | cimInstance = CIMInstance(className); |
| |
|
if (!empty) |
|
{ |
// Get QUALIFIER elements: | // Get QUALIFIER elements: |
|
|
getQualifierElements(parser, cimInstance); | getQualifierElements(parser, cimInstance); |
| |
// Get PROPERTY elements: | // Get PROPERTY elements: |
|
|
GetPropertyElements(parser, cimInstance); | GetPropertyElements(parser, cimInstance); |
| |
// Get INSTANCE end tag: | // Get INSTANCE end tag: |
|
|
expectEndTag(parser, "INSTANCE"); | expectEndTag(parser, "INSTANCE"); |
|
} |
| |
return true; | return true; |
} | } |
|
|
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
// Pending DMTF CR |
// | // |
// getErrorElement() |
// <!ELEMENT ERROR (INSTANCE*)> |
// |
|
// <!ELEMENT ERROR EMPTY> |
|
// <!ATTLIST ERROR | // <!ATTLIST ERROR |
// CODE CDATA #REQUIRED | // CODE CDATA #REQUIRED |
// DESCRIPTION CDATA #IMPLIED> | // DESCRIPTION CDATA #IMPLIED> |
|
|
entry.getAttributeValue("DESCRIPTION", tmpDescription); | entry.getAttributeValue("DESCRIPTION", tmpDescription); |
| |
if (!empty) | if (!empty) |
|
{ |
|
while (testStartTagOrEmptyTag(parser, entry)) |
|
{ |
|
skipElement(parser, entry); |
|
} |
|
|
expectEndTag(parser, "ERROR"); | expectEndTag(parser, "ERROR"); |
|
} |
| |
cimException = PEGASUS_CIM_EXCEPTION(CIMStatusCode(tmpCode), tmpDescription); | cimException = PEGASUS_CIM_EXCEPTION(CIMStatusCode(tmpCode), tmpDescription); |
return true; | return true; |
|
|
else if (!XmlReader::getClassPathElement(parser, reference)) | else if (!XmlReader::getClassPathElement(parser, reference)) |
{ | { |
| |
// l10n |
// l10n 485 |
| |
// throw XmlValidationError(parser.getLine(), | // throw XmlValidationError(parser.getLine(), |
// "Expected INSTANCEPATH or CLASSPATH element"); | // "Expected INSTANCEPATH or CLASSPATH element"); |
| |
MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_INSTANCEPATH_OR_CLASSPATH_ELEMENT", | MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_INSTANCEPATH_OR_CLASSPATH_ELEMENT", |
"Expected INSTANCEPATH or CLASSPATH element", "INSTANCEPATH", "CLASSPATH"); |
"Expected INSTANCEPATH or CLASSPATH element"); |
| |
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
|
|
// throw XmlValidationError(parser.getLine(), | // throw XmlValidationError(parser.getLine(), |
// "Expected LOCALINSTANCEPATH or LOCALCLASSPATH element"); | // "Expected LOCALINSTANCEPATH or LOCALCLASSPATH element"); |
| |
MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_LOCALINSTANCEPATH_OR_LOCALCLASSPATH_ELEMENT", |
//l10n updated |
"Expected LOCALINSTANCEPATH or LOCALCLASSPATH element"); |
MessageLoaderParms mlParms("Common.XmlConstants.MISSING_ELEMENT_LOCALPATH", |
|
MISSING_ELEMENT_LOCALPATH); |
| |
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
| |
|
|
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
|
|