Hi,

I tried to validate an XML document with soap envelope against a schema
which does not have the soap definition.  I get the error "Unknown element :
soap-env:ENVELOPE.

I validated the same document against the same schema in Altova XMLSpy where
it validated successfully.

I am using the following statements to parse the XML.


  DOMImplementation *impl =
DOMImplementationRegistry::getDOMImplementation(gLS);
  parser =
((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS,
0);

  parser->setFeature(XMLUni::fgDOMNamespaces, true);
  parser->setFeature(XMLUni::fgXercesSchema, true);
  parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
  parser->setFeature(XMLUni::fgDOMValidation, true);
  parser->setFeature(XMLUni::fgDOMValidateIfSchema, true);
  parser->setFeature(XMLUni::fgXercesCacheGrammarFromParse, true);
  parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
// enable datatype normalization
  parser->setFeature(XMLUni::fgDOMWhitespaceInElementContent, false);
// ignore white spaces
  parser->setFeature(XMLUni::fgXercesValidationErrorAsFatal, false);
// continue after validation error

  // Instantiate error handler and install it
  parser->setErrorHandler(&errorHandler);
  //reset error count first
  errorHandler.resetErrors();

  const char* msgInBuf = strMessage.data();
  MTidyPointer<MemBufInputSource> memBufIS;
  try {
    memBufIS = new MemBufInputSource(reinterpret_cast<const
XMLByte*>(msgInBuf),
                                                      static_cast<unsigned
int>(strlen(msgInBuf) * sizeof(XMLByte)),
                                                      memBufId,
                                                      false);
    memBufIS->setEncoding(0);
    // reset document pool
    parser->resetDocumentPool();
    // Load the schema.
    if (schemaLocation.length() != 0) {
      if (schemaLocation.contains(" ")) {
        parser->setProperty (XMLUni::fgXercesSchemaExternalSchemaLocation,
const_cast<XMLCh*>(XMLStringWrapper(schemaLocation).UnicodeForm()));
      } else {
        parser->setProperty
(XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation,
const_cast<XMLCh*>(XMLStringWrapper(schemaLocation).UnicodeForm()));
      }
    }

    Wrapper4InputSource wrapper(memBufIS);
    doc = parser->parse(wrapper);

Can anybody tell whether I should add anything more to the validating parser
to support soap envelope in my XML?  I want to know whether, to support
this, the schema also should use soap envelope?

Thanks in Advance

Mini.

Reply via email to