You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by an...@rwe.com on 2006/01/10 10:52:29 UTC

Access violation when validating multiple documents against a schema

Hi,

I use the following code to validate documents (tried to distill the
relevant bits). I suspect miss some cleanup I must do on the parser
before parsing the second document.
The first document is properly parsed (when valid, otherwise errors are
reported). The second document is parsed when it is valid. If it does
not conform to the schema I get an access violation
(a pointer to an instance of ComplexTypeInfo is 0, on call to
ComplexTypeInfo::getContentModel).

Any suggestions?

main() {
...
XMLPlatformUtils::Initialize(); 
... // error handling, etc..
... // create InputSources ...
 
doc1 = parseXML(  inputXML1  );
...
doc2 = parseXML(  inputXML2  );

...
XMLPlatformUtils::Terminate(); 

}
...
DOMDocument* parseXML( InputSource& inputXML ) {
	parser = new XercesDOMParser;
	parser->setValidationScheme( AbstractDOMParser::Val_Always );
	parser->setDoNamespaces( true );
	parser->setDoSchema( true );
	parser->setExternalSchemaLocation( "MY_SCHEMA_LOCATION" );

	parser->parse( inputXML );
	
	... 
	
	DOMDocument* doc = parser->adoptDocument();
	delete parser;
	
	return doc;
}



Thx,

Andreas

Andreas Sodeur 

RWE Trading GmbH
Structuring & Valuation
Huyssenallee 2, 45128 Essen
intern 70-17755
extern +49(0)201/12-177 55
mobile +49(0)163/63-177 55


Re: Access violation when validating multiple documents against a schema

Posted by Alberto Massari <am...@datadirect.com>.
Hi Andreas,
could you open a bug in Jira 
(http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10510) 
attaching a compilable testcase plus all the needed XML and XSD files?

Thanks,
Alberto

At 10:52 AM 1/10/2006 +0100, andreas.sodeur@rwe.com wrote:
>Hi,
>
>I use the following code to validate documents (tried to distill the
>relevant bits). I suspect miss some cleanup I must do on the parser
>before parsing the second document.
>The first document is properly parsed (when valid, otherwise errors are
>reported). The second document is parsed when it is valid. If it does
>not conform to the schema I get an access violation
>(a pointer to an instance of ComplexTypeInfo is 0, on call to
>ComplexTypeInfo::getContentModel).
>
>Any suggestions?
>
>main() {
>...
>XMLPlatformUtils::Initialize();
>... // error handling, etc..
>... // create InputSources ...
>
>doc1 = parseXML(  inputXML1  );
>...
>doc2 = parseXML(  inputXML2  );
>
>...
>XMLPlatformUtils::Terminate();
>
>}
>...
>DOMDocument* parseXML( InputSource& inputXML ) {
>         parser = new XercesDOMParser;
>         parser->setValidationScheme( AbstractDOMParser::Val_Always );
>         parser->setDoNamespaces( true );
>         parser->setDoSchema( true );
>         parser->setExternalSchemaLocation( "MY_SCHEMA_LOCATION" );
>
>         parser->parse( inputXML );
>
>         ...
>
>         DOMDocument* doc = parser->adoptDocument();
>         delete parser;
>
>         return doc;
>}
>
>
>
>Thx,
>
>Andreas
>
>Andreas Sodeur
>
>RWE Trading GmbH
>Structuring & Valuation
>Huyssenallee 2, 45128 Essen
>intern 70-17755
>extern +49(0)201/12-177 55
>mobile +49(0)163/63-177 55