// --------------------------------------------------------------------------- // XercesDOMParser: Setter methods // --------------------------------------------------------------------------- void XercesDOMParser::setErrorHandler(ErrorHandler* const handler) { fErrorHandler = handler; XMLScanner* scanner = getScanner(); if (fErrorHandler) { scanner->setErrorReporter(this); scanner->setErrorHandler(fErrorHandler); } else { scanner->setErrorReporter(0); scanner->setErrorHandler(0); } }
void SAXParser::useScanner(const XMLCh* const scannerName) { XMLScanner* tempScanner = XMLScannerResolver::resolveScanner ( scannerName , fValidator , fGrammarResolver , fMemoryManager ); if (tempScanner) { tempScanner->setParseSettings(fScanner); tempScanner->setURIStringPool(fURIStringPool); delete fScanner; fScanner = tempScanner; } }
void NsSAX2Reader::setProperty(const XMLCh* const name, void* value) { if (fParseInProgress) NsUtil::nsThrowException(XmlException::INTERNAL_ERROR, "Cannot setProperty during parse", __FILE__, __LINE__); if (XMLString::compareIString(name, XMLUni::fgXercesSchemaExternalSchemaLocation) == 0) { fScanner->setExternalSchemaLocation((XMLCh*)value); } else if (XMLString::compareIString(name, XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation) == 0) { fScanner->setExternalNoNamespaceSchemaLocation((XMLCh*)value); } else if (XMLString::compareIString(name, XMLUni::fgXercesSecurityManager) == 0) { fScanner->setSecurityManager((SecurityManager*)value); } else if (XMLString::equals(name, XMLUni::fgXercesScannerName)) { XMLScanner* tempScanner = XMLScannerResolver::resolveScanner ( (const XMLCh*) value , fValidator , fGrammarResolver , fMemoryManager ); if (tempScanner) { tempScanner->setParseSettings(fScanner); tempScanner->setURIStringPool(fURIStringPool); delete fScanner; fScanner = tempScanner; } } else NsUtil::nsThrowException(XmlException::INTERNAL_ERROR, "Unknown property in setProperty", __FILE__, __LINE__); }
// --------------------------------------------------------------------------- // Program entry point // --------------------------------------------------------------------------- int main(int argC, char** argV) { // Init the XML platform try { XMLPlatformUtils::Initialize(); } catch(const XMLException& toCatch) { XERCES_STD_QUALIFIER cout << "Error during platform init! Message:\n" << StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl; return 1; } // // Create our test parser object. This object implements the internal // event APIs and is plugged into the scanner. // TestParser parserTest; // Figure out the parameters bool doValidation = false; bool doNamespaces = false; bool keepGoing = false; XMLCh* urlPath = 0; for (int index = 1; index < argC; index++) { if (!XMLString::compareIString(argV[index], "/Debug")) parserTest.setOutputType(OutputType_Debug); else if (!XMLString::compareIString(argV[index], "/Validate")) doValidation = true; else if (!XMLString::compareIString(argV[index], "/Namespaces")) { doNamespaces = true; parserTest.setDoNamespaces(true); } else if (!XMLString::compareIString(argV[index], "/XML")) parserTest.setOutputType(OutputType_XML); else if (!XMLString::compareIString(argV[index], "/IntDTD")) parserTest.setShowIntDTD(true); else if (!XMLString::compareIString(argV[index], "/ShowWarnings")) parserTest.setShowWarnings(true); else if (!XMLString::compareIString(argV[index], "/ShowErrLoc")) parserTest.setShowErrLoc(true); else if (!XMLString::compareIString(argV[index], "/JCCanon")) parserTest.setOutputType(OutputType_JCCanon); else if (!XMLString::compareIString(argV[index], "/SunCanon")) parserTest.setOutputType(OutputType_SunCanon); else if (!XMLString::compareIString(argV[index], "/KeepGoing")) keepGoing = true; else if (!XMLString::compareNIString(argV[index], "/URL=", 5)) urlPath = XMLString::transcode(&argV[index][5]); else XERCES_STD_QUALIFIER cout << "Unknown parameter: " << argV[index] << XERCES_STD_QUALIFIER endl; } // We have to have a URL to work on if (!urlPath) { XERCES_STD_QUALIFIER cout << "A URL must be provided, /URL=xxxx" << XERCES_STD_QUALIFIER endl; return 1; } // // Create a validator of the correct type so that we can install it // on the scanner. // // <TBD> Later, when Schema validators exist, we'll have a parameter // to select one or the other // XMLValidator* validator = 0; DTDValidator* dtdVal = new DTDValidator(&parserTest); validator = dtdVal; // And now create the scanner and give it all the handlers XMLScanner scanner ( &parserTest , &parserTest , 0 , &parserTest , validator ); // Set the scanner flags that we were told to scanner.setDoValidation(doValidation); scanner.setDoNamespaces(doNamespaces); scanner.setExitOnFirstFatal(!keepGoing); // Tell the parser about the scanner parserTest.setScanner(&scanner); try { scanner.scanDocument(urlPath); } catch(const XMLException& toCatch) { XERCES_STD_QUALIFIER cout << "Exception during scan:\n " << StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl; } // And call the termination method XMLPlatformUtils::Terminate(); return 0; }