• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ XercesDOMParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中XercesDOMParser的典型用法代码示例。如果您正苦于以下问题:C++ XercesDOMParser类的具体用法?C++ XercesDOMParser怎么用?C++ XercesDOMParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了XercesDOMParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: readFile

void Parameters::readFile(string str){
  file = str;
  XMLPlatformUtils::Initialize();
  XercesDOMParser parser;
  parser.setValidationScheme(XercesDOMParser::Val_Always);
  HandlerBase errHandler;// = (ErrorHandler*) new HandlerBase();
  parser.setErrorHandler(&errHandler);
  parser.parse(str.c_str());
  DOMDocument * doc = parser.getDocument();
  DOMElement* elementRoot = doc->getDocumentElement();

  // Extract floats
  DOMElement* floatRoot = (DOMElement *) 
    elementRoot->getElementsByTagName(XMLString::transcode("real"))->item(0);
  DOMElement* child = floatRoot->getFirstElementChild();
  do{
    saveReal(XMLString::transcode(child->getNodeName()),  
		    atof(XMLString::transcode(child->getTextContent())));
    child = child->getNextElementSibling();
  }while(child != NULL);

  // Extract integers
  DOMElement* intRoot = (DOMElement *) 
    elementRoot->getElementsByTagName(XMLString::transcode("integer"))->item(0);
  child = intRoot->getFirstElementChild();
  do{
    saveInteger(
		    XMLString::transcode(child->getNodeName()),  
		    atoi(XMLString::transcode(child->getTextContent())));
    child = child->getNextElementSibling();
  }while(child != NULL);
}
开发者ID:varungupta181186,项目名称:vistool,代码行数:32,代码来源:parameters.cpp


示例2: XercesDOMParser

	void ItemDataLoader::loadData(string filename)
	{
		XMLPlatformUtils::Initialize();

		XmlHelper::initializeTranscoder();
		XercesDOMParser* parser = new XercesDOMParser();

        parser->setValidationScheme(XercesDOMParser::Val_Always);    // optional.
        parser->setDoNamespaces(true);    // optional
		
		XmlPtr res = XmlResourceManager::getSingleton().create(filename, 
			Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		res->parseBy(parser);

		DOMDocument* doc = parser->getDocument();
		DOMElement* dataDocumentContent = XmlHelper::getChildNamed(
            doc->getDocumentElement(), "Inhalt");

		initializeWeapons(XmlHelper::getChildNamed(dataDocumentContent, "Waffen"));
		initializeArmors(XmlHelper::getChildNamed(dataDocumentContent, "Rüstungen"));
		initializeItems(XmlHelper::getChildNamed(dataDocumentContent, "Gegenstände"));
		
		doc->release();

        res.setNull();
        XmlResourceManager::getSingleton().remove(filename);

		XMLPlatformUtils::Terminate();
	}
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:29,代码来源:ItemDataLoader.cpp


示例3: SAMLLoadSchema

static bool
SAMLLoadSchema(XercesDOMParser &parser,
               const SAMLGlibString &schemaDir,
               const char *filename)
{
   SAMLGlibString schemaPath(g_build_filename(schemaDir.c_str(), filename,
                                              NULL));
   Grammar *g = parser.loadGrammar(schemaPath.c_str(),
                                   Grammar::SchemaGrammarType, true);
   if (g == NULL) {
      /*
       * The parser complains even with official schemas, so we don't
       * normally set an error handler. However, this should not fail since
       * we control these files, so try again with logging, so we can see
       * what went wrong.
       */
      SAMLErrorHandler errorHandler;
      parser.setErrorHandler(&errorHandler);

      g = parser.loadGrammar(schemaPath.c_str(), Grammar::SchemaGrammarType,
                             true);

      Warning("Failed to load XML Schema from %s.\n", schemaPath.c_str());
      return false;
   }

   return true;
}
开发者ID:bzed,项目名称:pkg-open-vm-tools,代码行数:28,代码来源:saml-xml-security-c.cpp


示例4: readGenerations

void Generation::readGenerations(const string &file,
        vector<GenerationPtr> &generations) {
    XMLPlatformUtils::Initialize();
    XercesDOMParser parser;

    GenerationErrorHandler handler;
    parser.setErrorHandler(&handler);
    parser.setEntityResolver(&handler);

    parser.parse(file.c_str());

    DOMDocument *doc = parser.getDocument();
    DOMElement *root = doc->getDocumentElement();

    XMLCh tempStr[12];
    XMLString::transcode("generation", tempStr, 11);
    DOMNodeList *list = root->getElementsByTagName(tempStr);

    int length = list->getLength();
    for (int i = 0; i < length; ++i) {
        DOMElement *item = (DOMElement *)list->item(i);
        GenerationPtr generation(new Generation());
        generation->m_impl->m_owner = generation.get();
        generation->m_impl->getGeneration(item);
        generation->m_impl->m_idx = i;
        generations.push_back(generation);
    }
}
开发者ID:cathyjf,项目名称:PokemonLab,代码行数:28,代码来源:MetagameList.cpp


示例5: HandlerBase

map<string, DatasetSpecification> Specifications::readDatasetIndex(string str){
  map<string, DatasetSpecification> result;
  XERCES_CPP_NAMESPACE_USE
  XMLPlatformUtils::Initialize();
  XercesDOMParser parser;
  parser.setValidationScheme(XercesDOMParser::Val_Always);
  HandlerBase errHandler;// = (ErrorHandler*) new HandlerBase();
  parser.setErrorHandler(&errHandler);
  parser.parse(str.c_str());
  DOMDocument * doc = parser.getDocument();
  DOMElement* elementRoot = doc->getDocumentElement();
  DOMNodeList *entries = 
    elementRoot->getElementsByTagName(XMLString::transcode("dataset"));
  
  cout << "Databases in index:\n";
  for(size_t i = 0; i < entries->getLength(); ++i){
    DOMNode *current = entries->item(i);
    DatasetSpecification dss;
    dss.name = XMLString::transcode(current->getAttributes()->
				    getNamedItem(XMLString::transcode("name"))->
				    getNodeValue());
    dss.root = XMLString::transcode(current->getAttributes()->
				    getNamedItem(XMLString::transcode("root"))->
				    getNodeValue());
    cout << "  name: " << dss.name << " root: " << dss.root << endl;
    DOMNodeList *categories = current->getChildNodes();
    for(size_t j = 0; j < categories->getLength(); ++j)
      if((string) XMLString::transcode(categories->item(j)->getNodeName()) ==
	 "category")
	dss.categories.push_back(XMLString::transcode(categories->item(j)->getTextContent()));
    result[dss.name] = dss;
  }
  return result;
}
开发者ID:jelmervdl,项目名称:vistool,代码行数:34,代码来源:dataset.cpp


示例6:

bool SYSTEM::CXMLConfiguration::Open(std::string xmlpath)
{
    // ÅäÖýâÎö¹æÔò
    static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
    impl = DOMImplementationRegistry::getDOMImplementation(gLS);
    if(!impl)
        return false;
//		throw CException(GET_TEXT(ERR_XML_DOM_IMPLEMENTATION));
    if(parser == NULL)
        parser = new XercesDOMParser;
    XercesDOMParser* xmlparser = (XercesDOMParser*)parser;
    xmlparser->setValidationScheme(XercesDOMParser::Val_Never);
    xmlparser->setDoNamespaces(false);
    xmlparser->setDoSchema(false);
    xmlparser->setValidationSchemaFullChecking(false);
    xmlparser->setCreateEntityReferenceNodes(false);
    xmlparser->setIncludeIgnorableWhitespace(false);

    xmlparser->resetDocumentPool();	//ÖØÖÃÎĵµ»º³å³Ø
    xmlparser->parse(xmlpath.c_str());
    doc = xmlparser->getDocument();
    if(doc)
        itemElement = ((XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument*)doc)->getDocumentElement();	//¸³Óè¸ù½Úµã
    else
        return false;
    //throw CException(boost::str(boost::format(GET_TEXT(ERR_PARSE_CONFIG_FILE)) % xmlpath));

    xmlFile = xmlpath;
    return true;
}
开发者ID:lozpeng,项目名称:applesales,代码行数:30,代码来源:Configer.cpp


示例7: TestInit4DOM

// ---------------------------------------------------------------------------
//  DOM Parser
// ---------------------------------------------------------------------------
int TestInit4DOM(const char* xmlFile, bool gDoNamespaces, bool gDoSchema, bool gSchemaFullChecking, Teststate theState)
{
    TESTINITPRE;
    XercesDOMParser* parser = new XercesDOMParser;
    parser->setDoNamespaces(gDoNamespaces);
    parser->setDoSchema(gDoSchema);
    parser->setValidationSchemaFullChecking(gSchemaFullChecking);
    TESTINITPOST;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:12,代码来源:InitTermTest.cpp


示例8: openFile

bool XMLSceneryReader::openFile(const char* fileName) {

	bool result = false;

	XercesDOMParser* parser = new XercesDOMParser;
    
	parser->setValidationScheme(XercesDOMParser::Val_Never);
	parser->setDoSchema(false);
	parser->setLoadExternalDTD(false);
	parser->setErrorHandler(new XMLSceneryErrorHandler);

	parser->parse(LocalFileInputSource(XMLString::transcode(fileName)));

	if(!parser->getErrorCount()) {

		m_root = parser->getDocument()->getFirstChild();
		m_node = m_root;

		result = true;

	}

	return result;

}
开发者ID:BackupTheBerlios,项目名称:eu07-svn,代码行数:25,代码来源:XMLSceneryReader.cpp


示例9: printf

//
// domPrint  -  Dump the contents of a DOM node.
//              For debugging failures, when all else fails.
//                 Works recursively - initially called with a document node.
//
void ThreadParser::domPrint()
{
    printf("Begin DOMPrint ...\n");
    if (gRunInfo.dom)
    {
        try
        {
            XMLCh tempStr[100];
            XMLString::transcode("LS", tempStr, 99);
            DOMImplementation *impl          = DOMImplementationRegistry::getDOMImplementation(tempStr);
            DOMLSSerializer   *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
            DOMLSOutput       *theOutput     = ((DOMImplementationLS*)impl)->createLSOutput();
            XMLFormatTarget   *myFormTarget  = new StdOutFormatTarget();
            theOutput->setByteStream(myFormTarget);
            DOMNode           *doc           = fXercesDOMParser->getDocument();
            theSerializer->write(doc,theOutput);
            delete myFormTarget;
            theSerializer->release();
            theOutput->release();
        }
        catch (...)
        {
            // do nothing
        }
    }
    printf("End DOMPrint\n");
}
开发者ID:ideasiii,项目名称:ControllerPlatform,代码行数:32,代码来源:ThreadTest.cpp


示例10: XercesDOMParser

DOMDocument* DsaDataLoader::loadDataFile(string filename)
{

    XercesDOMParser* parser = new XercesDOMParser();
    parser->setValidationScheme(XercesDOMParser::Val_Always);    // optional.
    parser->setDoNamespaces(true);    // optional

    /*        ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase();
            parser->setErrorHandler(errHandler);*/

    XmlPtr res =
        XmlResourceManager::getSingleton().create(
            filename,
            Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    res.getPointer()->parseBy(parser);
    return parser->getDocument();
}
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:17,代码来源:DsaDataLoader.cpp


示例11: ParseXmlFromTMS

// 解析TMS返回xml
bool  CTMSSensor::ParseXmlFromTMS(std::string &retXml,int &nRet)
{
	XercesDOMParser *ptrParser = new  XercesDOMParser;
	ptrParser->setValidationScheme(  XercesDOMParser::Val_Never );
	ptrParser->setDoNamespaces( true );
	ptrParser->setDoSchema( false );
	ptrParser->setLoadExternalDTD( false );
	InputSource* ptrInputsource = new  MemBufInputSource((XMLByte*)retXml.c_str(), retXml.size(), "bufId");

	try
	{
		ptrParser->parse(*ptrInputsource);
		DOMDocument* ptrDoc = ptrParser->getDocument();	

		// 读取ret节点
		DOMNodeList *ptrNodeList = ptrDoc->getElementsByTagName(C2X("ret"));
		if(ptrNodeList == NULL)
		{
			LOGIDFMT(ULOG_ERROR,ERROR_PARSE_MONITORSTATE_XML,"ParseXmlFromTMS:ret");
			return false;
		}
		else 
		{
			if(ptrNodeList->getLength() == 0)
			{
				LOGIDFMT(ULOG_ERROR,ERROR_PARSE_MONITORSTATE_XML,"ParseXmlFromTMS:ret");
				return false;
			}
			DOMNode* ptrNode = ptrNodeList->item(0);
			char* pstate =  XMLString::transcode(ptrNode->getFirstChild()->getNodeValue());
			std::string str_state = pstate;
			if(!str_state.empty())
			{
				nRet = atoi(str_state.c_str());
			}
			XMLString::release(&pstate);
			//LOGINFFMT("%s,%s\n",str_name.c_str(),str_state.c_str());
		}
	}
	catch(  XMLException& e )
	{
		char* message =  XMLString::transcode( e.getMessage() );
		XMLString::release( &message );
		LOGIDFMT(ULOG_ERROR,ERROR_PARSE_MONITORSTATE_XML,message);
		delete ptrParser;
		ptrInputsource = NULL;
		delete ptrInputsource;
		ptrParser = NULL;
	}


	delete ptrParser;
	delete ptrInputsource;
	ptrInputsource = NULL;
	ptrParser = NULL;
	return true;
}
开发者ID:goodluckluyan,项目名称:IMonitor,代码行数:58,代码来源:TMSSensor.cpp


示例12: parseHTML

Parser* parseHTML(std::string contents) {
  try {
    XMLPlatformUtils::Initialize();
  } catch (const XMLException& toCatch) {
    char* msg = XMLString::transcode(toCatch.getMessage());
    cout << "INIT_ERR:" << endl;
    cout << msg << endl;
    XMLString::release(&msg);
    return NULL;
  }

  XercesDOMParser* parser = new XercesDOMParser();
  parser->setValidationScheme(XercesDOMParser::Val_Always);
  parser->setDoNamespaces(true);

  ErrorHandler* err = (ErrorHandler*) new HandlerBase();
  parser->setErrorHandler(err);

  try {
		MemBufInputSource xml((const XMLByte*)contents.c_str(), contents.size(), "html", false);
    parser->parse(xml);
		parser->adoptDocument();
		delete parser;
		delete err;
		XMLPlatformUtils::Terminate();
		return parser;
  } catch (const XMLException &toCatch) {
    char* msg = XMLString::transcode(toCatch.getMessage());
    cout << "XML_ERR: ";
    cout << msg << endl;
    XMLString::release(&msg);
    return parser;
  } catch (const DOMException &toCatch) {
    char* msg = XMLString::transcode(toCatch.getMessage());
    cout << "DOM_ERR: ";
    cout << msg << endl;
    XMLString::release(&msg);
    return parser;
  } catch (const SAXException &toCatch) {
		char* msg = XMLString::transcode(toCatch.getMessage());
		cout << "SAX_ERR: ";
		cout << msg << endl;
		XMLString::release(&msg);
		return parser;
	} catch (...) {
		cout << "!UNKNOWN_ERR!" << endl;
		return parser;
	}

  delete parser;
  delete err;

  XMLPlatformUtils::Terminate();

  return NULL;
}
开发者ID:gitter-badger,项目名称:modernkit,代码行数:56,代码来源:html.cpp


示例13: loadTranslations

bool 
CategoryTranslationLoader::loadTranslations( const MC2String& filename ) try {
   // load and parse file
   XercesDOMParser parser;
   parser.setValidationScheme( XercesDOMParser::Val_Auto );
   parser.setIncludeIgnorableWhitespace( false );

   parser.parse( filename.c_str() );

   if ( parser.getDocument() == NULL ) {
      return false;
   }

   loadTranslations( parser.getDocument() );

   return true;

} catch ( const XMLTool::Exception& e ) {
   // any xml exception here is bad.
   return false;
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-Server,代码行数:21,代码来源:CategoryTranslationLoader.cpp


示例14: myEppParser

int myEppParser (char* xsdPath, char* xmlPath)
{
	XMLPlatformUtils::Initialize();  // Initialize Xerces infrastructure
	XercesDOMParser parser;

	ParserErrorHandler parserErrorHandler;

	parser.setErrorHandler(&parserErrorHandler);

	// Enable schema processing.
	parser.setDoSchema(xsdValidationOn);

	// parser.setErrorHandler(&parserErrorHandler);
	parser.setValidationScheme(XercesDOMParser::Val_Auto);
	parser.setDoNamespaces(namespaceParsing);

	parser.cacheGrammarFromParse(true);
	// Let's preparse the schema grammar (.xsd) and cache it.
	loadXSD(xsdPath, &parser);
	validateXMLs(xmlPath, &parser);
	return 0;
}
开发者ID:neustar,项目名称:registrar_toolkit,代码行数:22,代码来源:EppNamespaceParser.cpp


示例15: XercesDOMParser

DOMDocument* tsp::Tool::parserXml(string myxml) {
	if (!initXmlEngine() || myxml.empty())
		return NULL;

	XercesDOMParser* parser = new XercesDOMParser();
	parser->setValidationScheme(XercesDOMParser::Val_Always);
	parser->setDoNamespaces(true);    // optional

	ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase();
	parser->setErrorHandler(errHandler);

	try {
		MemBufInputSource src((const XMLByte*) myxml.c_str(), myxml.length(),
				"dummy", false);

		parser->parse(src);

	} catch (const XMLException& toCatch) {
		char* message = XMLString::transcode(toCatch.getMessage());
		cout << "Exception message is: \n" << message << "\n";
		XMLString::release(&message);
		return NULL;
	} catch (const DOMException& toCatch) {
		char* message = XMLString::transcode(toCatch.msg);
		cout << "Exception message is: \n" << message << "\n";
		XMLString::release(&message);
		return NULL;
	} catch (...) {
		cout << "Unexpected Exception \n";
		return NULL;
	}

	DOMDocument* doc;
	doc = parser->getDocument();

	delete errHandler;
	return doc;
}
开发者ID:nhnghia,项目名称:TestGen-IFx,代码行数:38,代码来源:Tool.cpp


示例16: resIdentifier

DOMDocument *
XIncludeUtils::doXIncludeXMLFileDOM(const XMLCh *href,
                                    const XMLCh *relativeHref,
                                    DOMNode *includeNode,
                                    DOMDocument *parsedDocument,
                                    XMLEntityHandler* entityResolver){
    if (XIncludeUtils::isInCurrentInclusionHistoryStack(href)){
         /* including something back up the current history */
         XIncludeUtils::reportError(parsedDocument, XMLErrs::XIncludeCircularInclusionLoop,
              href, href);
         return NULL;
    }

    if (XMLString::equals(href, parsedDocument->getBaseURI())){
        /* trying to include itself */
        XIncludeUtils::reportError(parsedDocument, XMLErrs::XIncludeCircularInclusionDocIncludesSelf,
              href, href);
        return NULL;
    }

    /* Instantiate the DOM parser. */
    XercesDOMParser parser;
    parser.setDoNamespaces(true);
    /* don't want to recurse the xi processing here */
    parser.setDoXInclude(false);
    /* create the schema info nodes, so that we can detect conflicting notations */
    parser.setCreateSchemaInfo(true);
    XMLInternalErrorHandler xierrhandler;
    parser.setErrorHandler(&xierrhandler);

    DOMDocument *includedNode = NULL;
    try {
        InputSource* is=NULL;
        Janitor<InputSource> janIS(is);
        if(entityResolver) {
            XMLResourceIdentifier resIdentifier(XMLResourceIdentifier::ExternalEntity,
                                                relativeHref,
                                                NULL,
                                                NULL,
                                                includeNode->getBaseURI());
            is=entityResolver->resolveEntity(&resIdentifier);
            janIS.reset(is);
        }
        if(janIS.get()!=NULL)
            parser.parse(*janIS.get());
        else
            parser.parse(href);
        /* need to be able to release the parser but keep the document */
        if (!xierrhandler.getSawError() && !xierrhandler.getSawFatal())
            includedNode = parser.adoptDocument();
    }
    catch (const XMLException& /*toCatch*/)
    {
        XIncludeUtils::reportError(parsedDocument, XMLErrs::XIncludeResourceErrorWarning,
              href, href);
    }
    catch (const DOMException& /*toCatch*/)
    {
        XIncludeUtils::reportError(parsedDocument, XMLErrs::XIncludeResourceErrorWarning,
              href, href);
    }
    catch (...)
    {
        XIncludeUtils::reportError(parsedDocument, XMLErrs::XIncludeResourceErrorWarning,
             href, href);
    }

    //addDocumentURIToCurrentInclusionHistoryStack(href);

    if(includedNode != NULL){
        /* baseURI fixups - see http://www.w3.org/TR/xinclude/#base for details. */
        DOMElement *topLevelElement = includedNode->getDocumentElement();
        if (topLevelElement && topLevelElement->getNodeType() == DOMNode::ELEMENT_NODE ){
            XMLUri parentURI(includeNode->getBaseURI());
            XMLUri includedURI(includedNode->getBaseURI());

            /* if the paths differ we need to add a base attribute */
            if (!XMLString::equals(parentURI.getPath(), includedURI.getPath())){
                if (getBaseAttrValue(topLevelElement) == NULL){
                    /* need to calculate the proper path difference to get the relativePath */
                    topLevelElement->setAttribute(fgXIBaseAttrName, relativeHref);
                } else {
                    /* the included node has base of its own which takes precedence */
                    XIncludeLocation xil(getBaseAttrValue(topLevelElement));
                    if (getBaseAttrValue(includeNode) != NULL){
                        /* prepend any specific base modification of the xinclude node */
                        xil.prependPath(getBaseAttrValue(includeNode));
                    }
                    topLevelElement->setAttribute(fgXIBaseAttrName, xil.getLocation());
                }
            }
        }
    }
    return includedNode;
}
开发者ID:kanbang,项目名称:Colt,代码行数:95,代码来源:XIncludeUtils.cpp


示例17: read

void XMLRuntime::read(const string& filename, FreeAX25::Runtime::Configuration& config) {
    XercesDOMParser parser;
    parser.setValidationScheme(XercesDOMParser::Val_Always);
    parser.setDoNamespaces(true);
    parser.setDoSchema(true);
    parser.setDoXInclude(true);
    parser.setHandleMultipleImports(true);
    parser.setValidationSchemaFullChecking(true);
    parser.setCreateEntityReferenceNodes(false);
    parser.setIncludeIgnorableWhitespace(false);

    DOMTreeErrorReporter errReporter;
    parser.setErrorHandler(&errReporter);

    parser.parse(filename.c_str());

    if (errReporter.getSawErrors())
    	throw exception();

    // Now read configuration from the DOM Tree:
    XERCES_CPP_NAMESPACE::DOMDocument* doc = parser.getDocument();
    assert(doc != nullptr);

    auto rootElement = doc->getDocumentElement();
    auto configName = rootElement->getAttribute(toX("name"));
    config.setId(fmX(configName));

    { // Get settings:
		auto nodeList = rootElement->getElementsByTagName(toX("Settings"));
		if (nodeList->getLength() > 0)
			readSettings(
					"",
					static_cast<DOMElement*>(nodeList->item(0)),
					config.settings);
    }

    { // Get plugins:
		auto nodeList = rootElement->getElementsByTagName(toX("Plugins"));
		if (nodeList->getLength() > 0)
			readPlugins(
					"",
					static_cast<DOMElement*>(nodeList->item(0)),
					config.plugins);
    }
}
开发者ID:df9ry,项目名称:FreeAX25_Config,代码行数:45,代码来源:XMLRuntime.cpp


示例18: MessageBox

bool ColladaFile::Load(LPCWSTR lpszFileName)
{
	if( PathFileExists( lpszFileName ) == FALSE )
	{
		std::wstring strMessage;
		strMessage = strMessage + L"Colladaファイル[" + lpszFileName + L"]が見つかりませんでした";
		MessageBox( NULL, strMessage.c_str(), L"ColladaFile::Load()", MB_OK | MB_ICONERROR );
		return false;
	}

	XercesDOMParser* domParser = new XercesDOMParser();

	domParser->setValidationScheme( AbstractDOMParser::Val_Auto );	// 構文が特殊な場合にのみ報告する
    domParser->setDoNamespaces( false );							// 名前空間処理はしない
    domParser->setDoSchema( false );								// スキーマ処理はしない
    domParser->setValidationSchemaFullChecking( false );			// 完全な構文のチェックはしない

	DomErrorReporter* errorHandler = new DomErrorReporter();
	domParser->setErrorHandler( errorHandler );

	bool bException = false;
	try
	{
		domParser->parse( (const XMLCh*)lpszFileName );
	}
	catch( const OutOfMemoryException& )
	{
		MessageBox( NULL, L"XMLファイルを処理中にメモリが不足しました", L"ColladaFile::Load()-OutOfMemoryException", MB_OK | MB_ICONERROR );
		bException = false;
	}
	catch( const XMLException& ex )
	{
		std::wstring strMessage = L"XMLファイルを処理中にエラーが発生しました\n\n";
		strMessage += (const wchar_t*)ex.getMessage();
		MessageBox( NULL, strMessage.c_str(), L"ColladaFile::Load()-XMLException", MB_OK | MB_ICONERROR );
		bException = false;
	}
	catch( const DOMException& ex )
	{
		std::wstring strMessage = L"XMLファイルを処理中にエラーが発生しました\n\n";
		XMLCh temp[2048];
		DOMImplementation::loadDOMExceptionMsg( ex.code, temp, 2047 );
		strMessage += StrX( temp ).getStr();
		MessageBox( NULL, strMessage.c_str(), L"ColladaFile::Load()-DOMException", MB_OK | MB_ICONERROR );
		bException = false;
	}
	catch( ... )
	{
		MessageBox( NULL, L"XMLファイルを処理中にエラーが発生しました", L"ColladaFile::Load()", MB_OK | MB_ICONERROR );
		bException = false;
	}

	bool bError = bException || errorHandler->HasError();
	if( bError == false )	// エラーが発生しなかった場合はドキュメントを処理する
	{
		CreateColladaObject( dynamic_cast<DOMNode*>(domParser->getDocument()) );
		
		if( colladaObject->ValidElements() == false )
		{
			std::wstring strMessage = L"読み込まれたCOLLADAファイルが不完全です\n\n";
			strMessage += colladaObject->GetErrorMessage();
			MessageBox( NULL, strMessage.c_str(), L"COLLADAファイルの読み込み", MB_OK | MB_ICONWARNING );
			bError = true;
		}
	}
	else
	{
		std::wstring strMessage;
		if( errorHandler->GetFatalErrorMessage().empty() == false )
		{
			strMessage += L"致命的なエラー\n";
			strMessage += errorHandler->GetFatalErrorMessage();
		}

		if( errorHandler->GetErrorMessage().empty() == false )
		{
			strMessage += L"エラー\n";
			strMessage += errorHandler->GetErrorMessage();
		}

		if( strMessage.empty() == false )	// エラーメッセージがある場合は表示する
		{
			MessageBox( NULL, strMessage.c_str(), L"ColladaFile::Load()", MB_OK | MB_ICONERROR );
		}
	}

	delete errorHandler;
	delete domParser;

	return bError == false;
}
开发者ID:syoutetu,项目名称:ColladaViewer_VC8,代码行数:91,代码来源:ColladaFile.cpp


示例19: main

// ---------------------------------------------------------------------------
int
main(int argc, const char** argv)
{
   try
     {
       XMLPlatformUtils::Initialize();
     }
   catch(const XMLException& e)
     {
       StrX tmp_e(e.getMessage());
       cerr << "Xerces initialization error: " << tmp_e.localForm() << endl;
       return 2;
     }
   // check command line for arguments
   if ( argc < 1 )
     {
       cerr << "usage: schema-check <xml-file> [<schema-file> ...]" << endl;
       return 3;
     }
   XercesDOMParser *parser = new XercesDOMParser;
   DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter();
   parser->setErrorHandler(errReporter);
   parser->setDoNamespaces(true);
   parser->setCreateEntityReferenceNodes(true);
   parser->useCachedGrammarInParse(true);
   if ( argc > 2 )
     {
       parser->setDoSchema(true);
       parser->setDoValidation(true);
       parser->setValidationSchemaFullChecking(true);
       for ( int i = 2; i < argc; i++ )
         {

           if ( parser->loadGrammar(argv[i], Grammar::SchemaGrammarType, true) == 0 )
             {
               cerr << "Error loading grammar " << std::string(argv[i]) << endl;
               return 4;
             }
         }
     }
   bool errorsOccured = true;
   try
     {
       parser->parse(argv[1]);
       errorsOccured = false;
     }
   catch ( const OutOfMemoryException& )
     {
       cerr << "Out of memory exception." << endl;
     }
   catch ( const XMLException& e )
     {
       cerr << "An error occurred during parsing" << endl
            << "    Message: " << StrX(e.getMessage()) << endl;
     }
   catch ( const DOMException& e )
     {
       const unsigned int maxChars = 2047;
       XMLCh errText[maxChars + 1];
       cerr << endl
            << "DOM Error during parsing: '" << std::string(argv[1]) << "'" << endl
            << "DOM Exception code is: " << e.code << endl;
       if ( DOMImplementation::loadDOMExceptionMsg(e.code, errText, maxChars) )
         cerr << "Message is: " << StrX(errText) << endl;
     }
   catch (...)
     {
       cerr << "An error occurred during parsing." << endl;
     }
   return errorsOccured ? 1 : 0;
}
开发者ID:GunioRobot,项目名称:digital_cinema_tools,代码行数:72,代码来源:schema-check.cpp


示例20: Msg

//-----------------------------------------------------------------------------
// Purpose: load up a project and parse it
//-----------------------------------------------------------------------------
bool CVCProjConvert::LoadProject( const char *project )
{
#ifdef _WIN32
	HRESULT hr;
	IXMLDOMDocument *pXMLDoc=NULL;

	hr = ::CoCreateInstance(CLSID_DOMDocument, 
							NULL, 
							CLSCTX_INPROC_SERVER, 
							IID_IXMLDOMDocument, 
							(void**)&pXMLDoc);

	if (FAILED(hr))
	{
		Msg ("Cannot instantiate msxml2.dll\n");
		Msg ("Please download the MSXML run-time (url below)\n");
		Msg ("http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/001/766/msdncompositedoc.xml\n");
		return false;
	}

	VARIANT_BOOL vtbool;
	_variant_t bstrProject(project);

	pXMLDoc->put_async( VARIANT_BOOL(FALSE) );
	hr = pXMLDoc->load(bstrProject,&vtbool);
	if (FAILED(hr) || vtbool==VARIANT_FALSE)
	{
		Msg ("Could not open %s.\n", bstrProject);
		pXMLDoc->Release();
		return false;
	} 
#elif _LINUX
	XercesDOMParser* parser = new XercesDOMParser();
        parser->setValidationScheme(XercesDOMParser::Val_Always);    // optional.
        parser->setDoNamespaces(true);    // optional

        ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase();
        parser->setErrorHandler(errHandler);

        try {
            parser->parse(project);
        }
        catch (const XMLException& toCatch) {
            char* message = XMLString::transcode(toCatch.getMessage());
            Error( "Exception message is: %s\n", message );    
            XMLString::release(&message);
            return;
        }
        catch (const DOMException& toCatch) {
            char* message = XMLString::transcode(toCatch.msg);
            Error( "Exception message is: %s\n", message );    
            XMLString::release(&message);
            return;
        }
        catch (...) {
            Error( "Unexpected Exception \n" );
            return;
        }
	
	DOMDocument *pXMLDoc = parser->getDocument();
#endif

	ExtractProjectName( pXMLDoc );
	if ( !m_Name.IsValid() )
	{
		Msg( "Failed to extract project name\n" );
		return false;
	}
	char baseDir[ MAX_PATH ];
	Q_ExtractFilePath( project, baseDir, sizeof(baseDir) );
	Q_StripTrailingSlash( baseDir );
	m_BaseDir = baseDir;

	ExtractConfigurations( pXMLDoc );
	if ( m_Configurations.Count() == 0 )
	{
		Msg( "Failed to find any configurations to load\n" );
		return false;
	}

	ExtractFiles( pXMLDoc );

#ifdef _WIN32
	pXMLDoc->Release();
#elif _LINUX
	delete pXMLDoc;
	delete errHandler;
#endif

	m_bProjectLoaded = true;
	return true;
}
开发者ID:Epic-xx,项目名称:impending,代码行数:95,代码来源:vcprojconvert.cpp



注:本文中的XercesDOMParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Xml类代码示例发布时间:2022-05-31
下一篇:
C++ XeTeXFontInst类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap