Hi Jeff, Not sure why this isn't working for you. I am a little curious about why you're getting validation errors in case c); is this something you expect? i.e., are you using an invalid instance as your test case?
Have you tried calling lockPool() on your XMLGrammarPool implementation before initiating the parse? If you're using the default implementation, this will make sure that the XSModel is fluffed up. Cheers, Neil Neil Graham Manager, XML Parser Development IBM Toronto Lab Phone: 905-413-3519, T/L 969-3519 E-mail: [EMAIL PROTECTED] "Jeff Lynch" <[EMAIL PROTECTED]> 05/23/2005 11:41 AM Please respond to c-dev To <[email protected]> cc Subject PSVIHandler and UseCachedGrammarInParse at the same time? Hi All, I am curious if anyone has used both a PSVIHandler and fgXercesUseCachedGrammarInParse set to true and had satisfactory results? I figured that I would post a question to the list and then dive into debugging inside of xerces to see if I can figure out where it seemingly goes astray. Any help, suggested fixes or workarounds are appreciated. ----- The summary goes something like this: 1) Load and cache an XSD file from a resource into my own XSGrammarPool using ::loadGrammar. 2) Allocate a SAX2ReaderImpl using that grammar pool. 3) Set the PSVIHandler callback. 4) Parse an XML file (also from a resource). - I get reasonable data in the handlePartialElementPSVI and handleElementPSVI callbacks with fgXercesUseCachedGrammarInParse set to false (but this fails, since the version of the schema on the web is out of date). By reasonable data, I mean that I can call elementInfo->getTypeDefinition() in the callback and get Non-NULL data. 5) If I set fgXercesUseCachedGrammarInParse to true, I get NULL from calls to elementInfo->getTypeDefinition(), and furthermore, the parser crashes in SGXMLScanner::buildAttList (or IGXMLScanner::buildAttList, as I've tried both scanners), below the comment "// now fill in the PSVIAttributes entry for this attribute:" because the validatingType local variable is NULL (and the parser calls ::getVariety() on that null pointer. ----- I need to have both of these things working at the same time. I am first going to try to figure out why xerces cannot obtain the typeInfo successfully (see #5). ----- Other things I've tested: - NO PSVIHandler set, but WITH an error handler set and fgXercesUseCachedGrammarInParse set to true, the parse runs without errors. - I have used both the 2.6 code as well as the head revision from the now-read-only CVS archive without any change in the results. - I have tested both 2.6 and CVS on both Win32 (WinXP) and Mac OS X (10.4/Tiger). - I have tried using both the SGXMLScanner and IGXMLScanner during the parse. ----- Code details are here: m_pGrammarPool = new XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager); m_pSaxReader = new SAX2XMLReaderImpl(XMLPlatformUtils::fgMemoryManager, m_pGrammarPool); pGrammar = m_pSaxReader->loadGrammar(anInputSource, Grammar::SchemaGrammarType, true); m_pParser->setFeature(XMLUni::fgSAX2CoreValidation, true); m_pParser->setFeature(XMLUni::fgXercesDynamic, true); m_pParser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true); m_pParser->setFeature(XMLUni::fgXercesSchema, true); m_pParser->setFeature(XMLUni::fgXercesSchemaFullChecking, true); m_pParser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, true); m_pParser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true); // #1 m_pParser->setProperty(XMLUni::fgXercesScannerName, (void*)XMLUni::fgSGXMLScanner); m_pParser->setErrorHandler(m_pXercesSaxHandler); m_pParser->setPSVIHandler(m_pXercesSaxHandler); // #2 Three scenarios: A) With #1 set to true and #2 in place, we get null TypeInfo in the PSVI element callbacks and a parser crash. B) With #1 set to false and #2 in place, we get correct TypeInfo in the PSVI element callbacks, but validation failure because it doesn't look for the cached grammar. C) With #1 set to true and #2 commented out (i.e. no PSVIHandler set), the validation fails (but clearly we don't get any PSVI info (which I need for my application)). ----- Thanks again for any input or direction (off to do some debugging)... - j e f f --------------- jeffrey.w.lynch Mindjet, Inc. www.mindjet.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
