HI,
I have the same problem...and using same Parser..it never fails...
m_ConfigFileParser = new XercesDOMParser();
m_ConfigFileParser->cacheGrammarFromParse(true);
m_ConfigFileParser->setDoSchema(true);
m_ConfigFileParser->setValidationScheme(XercesDOMParser::Val_Auto);
m_ConfigFileParser->setDoNamespaces(true);
m_ConfigFileParser->setExternalNoNamespaceSchemaLocation("v4.xsd");
m_ConfigFileParser->loadGrammar("v4.xsd", Grammar::SchemaGrammarType,
true);
m_ConfigFileParser->parse("sample.xml");
do u see any thing wrong here...
little more new comer Q: how to do check this parse went good or not....
at present,sample.xml does not hold good with my xsd...
still able to walk thr' my XML....
thanks,
On Wed, Aug 12, 2009 at 10:54 PM, NathanN2 <[email protected]>wrote:
>
> 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.
>
>