当前位置: 首页>>代码示例>>C++>>正文


C++ DOMDocument::createNSResolver方法代码示例

本文整理汇总了C++中DOMDocument::createNSResolver方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMDocument::createNSResolver方法的具体用法?C++ DOMDocument::createNSResolver怎么用?C++ DOMDocument::createNSResolver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DOMDocument的用法示例。


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

示例1: document

std::vector<std::string> GetXpathResults1(DOMElement* root, std::string querystr)
{
	std::vector<std::string> values;

	DOMDocument* document (root->getOwnerDocument ());

	// Obtain namespace resolver.
	xsd::cxx::xml::dom::auto_ptr<XQillaNSResolver> resolver (
		(XQillaNSResolver*)document->createNSResolver (root));

	//// Create XPath expression.
	//xsd::cxx::xml::dom::auto_ptr<const XQillaExpression> expr (
	//	static_cast<const XQillaExpression*> (
	//	doc->createExpression (
	//	xsd::cxx::xml::string (querystr.c_str()).c_str (),
	//	resolver.get ())));
	//

	//// Execute the query.
	//xsd::cxx::xml::dom::auto_ptr<XPath2Result> r (
	//	static_cast<XPath2Result*> (
	//	expr->evaluate (
	//	doc, XPath2Result::ITERATOR_RESULT, 0)));

	// Parse an XPath 2 expression
	xsd::cxx::xml::dom::auto_ptr<DOMXPathExpression> expression(
		document->createExpression(X (querystr.c_str()), resolver.get ()));

	// Execute the query
	xsd::cxx::xml::dom::auto_ptr<DOMXPathResult> xQillaResult(
		expression->evaluate(
		document,
		DOMXPathResult::ITERATOR_RESULT_TYPE, 0));


	//		root, DOMXPathResult::ORDERED_NODE_SNAPSHOT_TYPE  /*DOMXPathResult::ITERATOR_RESULT_TYPE*/, 0));
	// Not sure it is an ordered list
	while (xQillaResult->iterateNext ())
	{
		//const DOMNode* n (r->asNode ());
		//const XMLCh * value = n->getTextContent	(		);
		char * value = XMLString::transcode(xQillaResult->getStringValue());
		values.push_back(value);
		delete value;

	}
	return values;
}
开发者ID:usnistgov,项目名称:QIF,代码行数:48,代码来源:XercesUtils.cpp

示例2: doc

std::vector<std::string> CXercesUtils::GetXpathResults(DOMElement* root, std::string querystr)
{
	std::vector<std::string> values;

	DOMDocument* doc (root->getOwnerDocument ());

	// Obtain namespace resolver.
	xsd::cxx::xml::dom::auto_ptr<DOMXPathNSResolver> resolver (
		doc->createNSResolver (root));

	// Create XPath expression.
	xsd::cxx::xml::dom::auto_ptr<DOMXPathExpression> expr (
		doc->createExpression (
		xsd::cxx::xml::string (querystr.c_str()).c_str (),
		resolver.get ()));

	// Execute the query.
	xsd::cxx::xml::dom::auto_ptr<DOMXPathResult> r (
		expr->evaluate (
		root, DOMXPathResult::ORDERED_NODE_SNAPSHOT_TYPE  /*DOMXPathResult::ITERATOR_RESULT_TYPE*/, 0));

	// If no query matches, then return empty vector
	if (!r.get() ) 
		return values;

	// Iterate over the result.
	for (int i=0; i < r->getSnapshotLength(); i++) 
	{
		r->snapshotItem(i);
		DOMNode* n (r->getNodeValue ());
		const XMLCh * value = n->getTextContent	(		);
		values.push_back(xsd::cxx::xml::transcode<char> (value));
	}

	return values;
}
开发者ID:usnistgov,项目名称:QIF,代码行数:36,代码来源:XercesUtils.cpp

示例3: Read

bool XmlWorldReader::Read(const std::string &file) {
	// ワールドを初期化
	try {
		initialize();
		if (initFlag) {
			initializeWorld();
		}
	} catch (...) {
		return false;
	}

	// TODO: ファイルの有無を確認

	// XMLファイルをパース
	const XMLCh gLS[] = {chLatin_L, chLatin_S, chNull};
	DOMImplementationLS *impl = DOMImplementationRegistry::getDOMImplementation(gLS);
	DOMLSParser *parser = impl->createLSParser(
		DOMImplementationLS::MODE_SYNCHRONOUS, NULL
	);
	DOMDocument *doc = parser->parseURI(file.c_str());
	if (doc == nullptr) {
		return false;
	}

	// rootノードを取得
	DOMElement *worldElement = doc->getDocumentElement();
	if (worldElement == nullptr) {
		parser->release();
		return false;
	}
	{
		YPT::XmlString temp("world");
		bool res = XMLString::equals(worldElement->getNodeName(), temp);
		if (!res) {
			parser->release();
			return false;
		}
	}

	// ロード用クラス作成
	YPT::XmlWorldPartReader partReader(doc);

	// XPathコンテキスト作成
	DOMXPathNSResolver *resolver = doc->createNSResolver(worldElement);
	if (resolver == nullptr) {
		parser->release();
		return false;
	}

	YPT::XmlString str, str2;
	DOMXPathResult *result;

	// --------------------------------------------------
	// ワールド全体の設定
	// --------------------------------------------------

	// ワールド名
	str = worldElement->getAttribute(YPT::XmlString("name"));
	if (str != "") {
		name = str;
	}

	// 重力ベクトル
	result = doc->evaluate(
		YPT::XmlString("./gravity"), worldElement, resolver,
		DOMXPathResult::ORDERED_NODE_SNAPSHOT_TYPE,
		NULL
	);
	if (result != nullptr) {
		if (result->getSnapshotLength() >= 1) {
			str = result->getNodeValue()->getTextContent();
			b2Vec2 temp;
			if (!YPT::ConvertStrToVec2(str.ToChar(), &temp)) {
				world.SetGravity(temp);
			}
		}
		result->release();
	}

	// --------------------------------------------------
	// shapes
	// --------------------------------------------------

	result = doc->evaluate(
		YPT::XmlString("./shape"), worldElement, resolver,
		DOMXPathResult::ORDERED_NODE_SNAPSHOT_TYPE,
		NULL
	);
	if (result != nullptr) {
		const XMLSize_t len = result->getSnapshotLength();
		for (XMLSize_t i = 0; i < len; ++i) {
			result->snapshotItem(i);
			DOMNode *node = result->getNodeValue();
			if (node == nullptr) {
				continue;
			}
			DOMNamedNodeMap *nodeMap = node->getAttributes();
			if (nodeMap == nullptr) {
				continue;
			}
//.........这里部分代码省略.........
开发者ID:yupotown,项目名称:Box2Dxml_Xerces,代码行数:101,代码来源:xmlworldreader.cpp

示例4: main


//.........这里部分代码省略.........

            if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, gFormatPrettyPrint))
                serializerConfig->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, gFormatPrettyPrint);

            if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTBOM, gWriteBOM))
                serializerConfig->setParameter(XMLUni::fgDOMWRTBOM, gWriteBOM);

            //
            // Plug in a format target to receive the resultant
            // XML stream from the serializer.
            //
            // StdOutFormatTarget prints the resultant XML stream
            // to stdout once it receives any thing from the serializer.
            //
            XMLFormatTarget *myFormTarget;
            if (goutputfile)
                myFormTarget=new LocalFileFormatTarget(goutputfile);
            else
                myFormTarget=new StdOutFormatTarget();
            theOutputDesc->setByteStream(myFormTarget);

            // get the DOM representation
            DOMDocument *doc = parser->getDocument();

            //
            // do the serialization through DOMLSSerializer::write();
            //
            if(gXPathExpression!=NULL)
            {
                XMLCh* xpathStr=XMLString::transcode(gXPathExpression);
                DOMElement* root = doc->getDocumentElement();
                try
                {
                    DOMXPathNSResolver* resolver=doc->createNSResolver(root);
                    DOMXPathResult* result=doc->evaluate(
                      xpathStr,
                      root,
                      resolver,
                      DOMXPathResult::ORDERED_NODE_SNAPSHOT_TYPE,
                      NULL);

                    XMLSize_t nLength = result->getSnapshotLength();
                    for(XMLSize_t i = 0; i < nLength; i++)
                    {
                      result->snapshotItem(i);
                      theSerializer->write(result->getNodeValue(), theOutputDesc);
                    }

                    result->release();
                    resolver->release ();
                }
                catch(const DOMXPathException& e)
                {
                    XERCES_STD_QUALIFIER cerr << "An error occurred during processing of the XPath expression. Msg is:"
                        << XERCES_STD_QUALIFIER endl
                        << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
                    retval = 4;
                }
                catch(const DOMException& e)
                {
                    XERCES_STD_QUALIFIER cerr << "An error occurred during processing of the XPath expression. Msg is:"
                        << XERCES_STD_QUALIFIER endl
                        << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
                    retval = 4;
                }
                XMLString::release(&xpathStr);
开发者ID:QEver,项目名称:vosproj,代码行数:67,代码来源:DOMPrint.cpp

示例5: main

int main(int argc, char *argv[])
{
	if (argc < 5)
	{
		cout << currentDateTime()  << "Usage: GTTagging.exe video_path flag_roi(1=true, 0=false) flag_load(1=true, 0=false) flag_saveROI(1=true, 0=false)\n";
		return 1;
	}

	/*serialize_video();*/
	string outFilename = "output_video.xml";
	serializeVideo(outFilename);
	removeTrailingSpace(outFilename);

	path video_path (argv[1]);

	string video_name = video_path.filename().replace_extension("").string();

	cout << "video_path filename: " << video_name << endl;

	string base_name = video_path.filename().replace_extension("").string();
	cout << "base_name: " << base_name << endl;

	string base_path = video_path.remove_filename().string();
	cout << "base_path: " << base_path << endl;	

	ostringstream codebook_paramters_path;

	codebook_paramters_path << base_path << "\\" << base_name << "_cparameters.dat";
	cout << "cparameters filename: " <<  codebook_paramters_path.str() << endl;	

	ostringstream xml_path;

	xml_path << base_path << "\\" << base_name << ".xml";
	cout << "xml filename: " <<  xml_path.str() << endl;

	path gt_xml_path (xml_path.str());
	
	try {
		
		XMLPlatformUtils::Initialize();	
		XQillaPlatformUtils::initialize();

	} catch (const XMLException& eXerces) {
		cerr << "Error during Xerces-C initialisation.\n"
			<< "Xerces exception message: "
			<< UTF8(eXerces.getMessage()) << endl;
		return 1;
	}

	try
	{
		if (!exists(gt_xml_path))
		{
			cout << currentDateTime()  << "File: " << gt_xml_path << " doesn't exist!" << endl;
			return 1;
		}

		if (!exists(video_path))
		{
			cout << currentDateTime()  << "File: " << video_path << " doesn't exist!" << endl;
			return 1;
		}		

		cout << currentDateTime()  << "Processing " << video_path << " ..." << endl;

		DOMImplementation* xqillaImplementation = DOMImplementationRegistry::getDOMImplementation(X("XPath2 3.0"));

		DOMLSParser* xmlParser = xqillaImplementation->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0);

		DOMConfiguration* dc_parser = xmlParser->getDomConfig();

		dc_parser->setParameter(XMLUni::fgDOMNamespaces, true);
		dc_parser->setParameter(XMLUni::fgXercesSchema, true);
		dc_parser->setParameter(XMLUni::fgDOMValidate, true);

		DOMDocument* document = xmlParser->parseURI(xml_path.str().c_str());

		if(document == 0) {
			cerr << "Document not found: " << xml_path.str().c_str() << endl;
			return 1;
		}

		const DOMXPathNSResolver* resolver = document->createNSResolver(document->getDocumentElement());

		XQillaNSResolver* xqillaResolver = (XQillaNSResolver*)resolver;
		xqillaResolver->addNamespaceBinding(X("xs"), X("http://www.w3.org/2001/XMLSchema"));	
		xqillaResolver->addNamespaceBinding(X("fn"), X("http://www.w3.org/2005/xpath-functions"));			

		// Initialize Subsense
		cv::VideoCapture oVideoInput;

		cv::Mat oCurrInputFrame, oCurrSegmMask, oCurrReconstrBGImg;	

		oVideoInput.open(argv[1]);
		oVideoInput >> oCurrInputFrame;
		oVideoInput.set(CV_CAP_PROP_POS_FRAMES,0);	

		// create BGS Subsense object
		BackgroundSubtractorSuBSENSE oBGSAlg;

//.........这里部分代码省略.........
开发者ID:gcypds,项目名称:sprCV,代码行数:101,代码来源:main.cpp


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