Hi

I am using the XercesDOMParser to validate (against an xsd schema) XML
documents that *should not* contain namespace or schema location
information. I do this (successfully) by using the parser's
'setExternalNoNamespaceSchemaLocation()' function.

My next goal is to prevent those same documents from ever specifying schema
locations or namespaces so that my validation cannot be tricked - ie. I want
to only ever validate these documents against my schema, and any other
schema references should be ignored. I thought this would be possible by
instantiating my parser like:

XMLGrammarPool* grammarPool = new
XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager);
XercesDOMParser* parser = new XercesDOMParser(NULL,
XMLPlatformUtils::fgMemoryManager, grammarPool);

... and then using:

grammarPool->lockPool();
grammarPool->unlockPool();
grammarPool->clear();
parser->loadGrammar(
    schemaLocation
    Grammar::SchemaGrammarType,
    true
);

... to control what schema grammars the parser knows about.

However this does not appear to work. When I attempt to parse and validate
the following document (which does not conform to one of my schemas) I do
not get any validation errors!

<xt:test
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xmlns:xt="extra"
    xsi:schemaLocation="extra ~~extraSchemaPath~~"
>
     This 
    should
    <c>fail!</c>
</xt:test>

Is there something obvious that I am doing wrong?

Regards

Nathan

p.s. I would be happy to post a little more of my code if necessary.




I have recently 

I have successfully validated 
-- 
View this message in context: 
http://www.nabble.com/Validation-and-grammar-usage.-tp24949266p24949266.html
Sent from the Xerces - C - Users mailing list archive at Nabble.com.

Reply via email to