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


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

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


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

示例1: main

int main(int argc, char *argv[]) {
  // Initialise Xerces-C and XQilla using XQillaPlatformUtils
  XQillaPlatformUtils::initialize();

  // Get the XQilla DOMImplementation object
  DOMImplementation *xqillaImplementation =
    DOMImplementationRegistry::getDOMImplementation(X("XPath2 3.0"));

  try {
    // Create a DOMLSParser object
    AutoRelease<DOMLSParser> parser(xqillaImplementation->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0));
    parser->getDomConfig()->setParameter(XMLUni::fgDOMNamespaces, true);
    parser->getDomConfig()->setParameter(XMLUni::fgXercesSchema, true);
    parser->getDomConfig()->setParameter(XMLUni::fgDOMValidateIfSchema, true);

    // Parse a DOMDocument
    DOMDocument *document = parser->parseURI("foo.xml");
    if(document == 0) {
      std::cerr << "Document not found." << std::endl;
      return 1;
    }

    // Parse an XPath 2 expression
    AutoRelease<DOMXPathExpression> expression(document->createExpression(X("foo/bar/@baz"), 0));

    // Execute the query
    AutoRelease<DOMXPathResult> result(expression->evaluate(document, DOMXPathResult::ITERATOR_RESULT_TYPE, 0));

    // Create a DOMLSSerializer to output the nodes
    AutoRelease<DOMLSSerializer> serializer(xqillaImplementation->createLSSerializer());
    AutoRelease<DOMLSOutput> output(xqillaImplementation->createLSOutput());
    StdOutFormatTarget target;
    output->setByteStream(&target);

    // Iterate over the results, printing them
    while(result->iterateNext()) {
      serializer->write(result->getNodeValue(), output);
      std::cout << std::endl;
    }
  }
  catch(XQillaException &e) {
    std::cerr << "XQillaException: " << UTF8(e.getString()) << std::endl;
    return 1;
  }

  // Terminate Xerces-C and XQilla using XQillaPlatformUtils
  XQillaPlatformUtils::terminate();

  return 0;
}
开发者ID:kanbang,项目名称:Colt,代码行数:50,代码来源:dom-context-item.cpp

示例2: 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

示例3: 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

示例4: main


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

		oBGSAlg.saveCodebookParametersPath(codebook_paramters_path.str());
		oBGSAlg.initialize(oCurrInputFrame, R);

		// create visualization windows
		/*cv::namedWindow("input",cv::WINDOW_AUTOSIZE);
		cv::namedWindow("segmentation mask",cv::WINDOW_AUTOSIZE);*/

		int xml_roi_counter = 0;
		int bgs_roi_counter = 0;
		
		int frame_counter = 0;
		//loop through video frames
		while(1) {							
			try {
				std::cout << "frame counter = " << frame_counter << std::endl;
				oVideoInput >> oCurrInputFrame;

				if(oCurrInputFrame.empty())
					break;

				//Process
				oBGSAlg(oCurrInputFrame,oCurrSegmMask);
				//oBGSAlg.getBackgroundImage(oCurrReconstrBGImg);
				std::vector<F_state_struct> F_states;

				// TODO Add function to static lib.
				getRegions(oCurrSegmMask, F_states, pminArea);

				std::ostringstream object_xpath_expression;
				object_xpath_expression << "//object[../@id=\""<< frame_counter++ << "\"]";
				cout << currentDateTime()  << "object_xpath_expression: " << object_xpath_expression.str() << endl;

				const DOMXPathExpression* parsedExpression = document->createExpression(X(object_xpath_expression.str().c_str()), resolver);

				DOMXPathResult* iteratorResult = (DOMXPathResult*)parsedExpression->evaluate(document->getDocumentElement(), DOMXPathResult::ITERATOR_RESULT_TYPE, 0);

				/*ostringstream xml_rois_path;

				xml_rois_path << base_path << "\\" << base_name << "_xml_rois";
				cout << "xml_rois_path filename: " <<  xml_rois_path.str() << endl;

				path xml_rois_dir (xml_rois_path.str());				

				if(!exists(xml_rois_dir)) {
					if (create_directories(xml_rois_dir)) {
						cout << currentDateTime()  << "xml_rois_dir created!" << endl;												
					} else {
						cout << currentDateTime()  << "Cannot create xml_rois_dir!" << endl;
						return 1;
					}
				}*/

				ostringstream bgs_rois_path;

				bgs_rois_path << base_path << "\\" << base_name << "_bgs_rois";
				cout << "bgs_rois_path filename: " <<  bgs_rois_path.str() << endl;

				path bgs_rois_dir (bgs_rois_path.str());

				if(!exists(bgs_rois_dir)) {
					if (create_directories(bgs_rois_dir)) {
						cout << currentDateTime()  << "bgs_rois_dir created!" << endl;												
					} else {
						cout << currentDateTime()  << "Cannot create bgs_rois_dir!" << endl;
						return 1;
开发者ID:gcypds,项目名称:sprCV,代码行数:67,代码来源:main.cpp


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