Hi, Please send questions about Xerces-C++ to the [email protected] mailing list (CC'ed) instead of to me directly. This way you can reach a wider audience of Xerces-C++ users/developers and get answers to your questions faster.
Boris [email protected] <[email protected]> writes: > Hi, > > > I started to work with xerces 3.0 and I need to validate one xml against xsd > , but my xsd had an include and import. > When I execute "parser->parse(lXml)", the parse don’t validate the xml > correctly, return just some errors as bellow and not > > all the occurrences. > > > “Errors returned”> > Line 2, Column 2: The 'http://www.portalfiscal.inf.br/nfe:nfeProc' element is > not declared. > Line 2, Column 10: Could not find schema information for the attribute > 'versao'. > > > “Errors expected”> > > Line 2, Column 2: The 'http://www.portalfiscal.inf.br/nfe:nfeProc' element is > not declared. > Line 2, Column 10: Could not find schema information for the attribute > 'versao'. > Line 165, Column 2: The 'http://www.portalfiscal.inf.br/nfe:protNFe' element > is not declared. > Line 165, Column 10: Could not find schema information for the attribute > 'versao'. > Line 166, Column 4: The 'http://www.portalfiscal.inf.br/nfe:infProt' element > is not declared. > Line 166, Column 12: Could not find schema information for the attribute 'Id'. > Line 167, Column 6: The 'http://www.portalfiscal.inf.br/nfe:tpAmb' element is > not declared. > Line 168, Column 6: The 'http://www.portalfiscal.inf.br/nfe:verAplic' element > is not declared. > Line 169, Column 6: The 'http://www.portalfiscal.inf.br/nfe:chNFe' element is > not declared. > Line 170, Column 6: The 'http://www.portalfiscal.inf.br/nfe:dhRecbto' element > is not declared. > Line 171, Column 6: The 'http://www.portalfiscal.inf.br/nfe:nProt' element is > not declared. > Line 172, Column 6: The 'http://www.portalfiscal.inf.br/nfe:digVal' element > is not declared. > Line 173, Column 6: The 'http://www.portalfiscal.inf.br/nfe:cStat' element is > not declared. > Line 174, Column 6: The 'http://www.portalfiscal.inf.br/nfe:xMotivo' element > is not declared. > > > Could you help me ? > > > > Follow as the code that I am running: > > > //this is a path of xsd root , this xsd had include and import > WideString lCaminhoXSD1 = "C:/DESENV/BIN/SCHEMAS_XML/nfe_v1.10.xsd"; > > //Path my xml to validate > WideString lXml = > "C:/DESENV/BIN/XML/35090163027692000181550000000003010000003011.xml"; > > MemoryManager *memMgr = new MemoryManagerImpl(); > > XMLPlatformUtils::Initialize (XMLUni::fgXercescDefaultLocale, 0, 0, memMgr); > > // Create a SAX2 parser object. > TWDefaultHandler handler; > > SAX2XMLReader* parser = XMLReaderFactory::createXMLReader(); > > parser->setProperty(XMLUni::fgXercesScannerName, (void > *)XMLUni::fgSGXMLScanner); > > parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true); > parser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes , true); > parser->setFeature(XMLUni::fgSAX2CoreValidation, true); > parser->setFeature(XMLUni::fgXercesDynamic, false); > parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true); > parser->setFeature(XMLUni::fgXercesLoadSchema, true); > parser->setFeature(XMLUni::fgXercesSchema, true); > parser->setFeature(XMLUni::fgXercesCacheGrammarFromParse, true); > parser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true); > > parser->setExitOnFirstFatalError(false); > parser->setValidationConstraintFatal(false); > > parser->setContentHandler(&handler); > parser->setErrorHandler(&handler); > parser->setEntityResolver(&handler); > > > // I load just one, but in the same directory there are others with i need, > because this a use "EntityResolver". > parser->loadGrammar(lCaminhoXSD1, Grammar::SchemaGrammarType, true); > > // Parse the XML document. > // Document content sent to registered ContentHandler instance. > try > { > parser->parse(lXml); > } > catch(SAXException e) > { > ShowMessage(e.getMessage()); > } -- Boris Kolpackov, Code Synthesis Tools http://codesynthesis.com/~boris/blog Open source XML data binding for C++: http://codesynthesis.com/products/xsd Mobile/embedded validating XML parsing: http://codesynthesis.com/products/xsde
