Boolean ProcessCimElement(CIMRepository& repository, XmlParser& parser) { XmlEntry entry; if (!parser.next(entry) || entry.type != XmlEntry::XML_DECLARATION) { throw(parser.getLine(), "expected XML declaration"); } if (!XmlReader::testStartTag(parser, entry, "CIM")) return false; String cimVersion; if (!entry.getAttributeValue("CIMVERSION", cimVersion)) { throw XmlValidationError(parser.getLine(), "missing CIM.CIMVERSION attribute"); } String dtdVersion; if (!entry.getAttributeValue("DTDVERSION", dtdVersion)) { throw XmlValidationError(parser.getLine(), "missing CIM.DTDVERSION attribute"); } if (!ProcessDeclarationElement(repository, parser)) { throw XmlValidationError(parser.getLine(), "Expected DECLARATION element"); } XmlReader::expectEndTag(parser, "CIM"); return true; }
static void testWhitespaceHandling() { char text[] = "<tag attr=\"\r\nvalue + \">\r\nvalue + </tag>"; XmlParser parser(text); XmlEntry entry; // Make sure attribute value has whitespace normalized. parser.next(entry); const char* attrValue; PEGASUS_TEST_ASSERT(entry.getAttributeValue("attr", attrValue)); PEGASUS_TEST_ASSERT(strcmp(attrValue, "value +") == 0); // Make sure element value has leading and trailing whitespace trimmed, // but internal whitespace is not compressed. parser.next(entry); PEGASUS_TEST_ASSERT(entry.type == XmlEntry::CONTENT); PEGASUS_TEST_ASSERT(strcmp(entry.text, "value +") == 0); }