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


C++ xpath函数代码示例

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


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

示例1: reader

bool Container::Open(const string& path)
{
	_archive = Archive::Open(path.stl_str());
	if (_archive == nullptr)
		throw std::invalid_argument(_Str("Path does not point to a recognised archive file: '", path, "'"));
	_path = path;

	// TODO: Initialize lazily? Doing so would make initialization faster, but require
	// PackageLocations() to become non-const, like Packages().
	ArchiveXmlReader reader(_archive->ReaderAtPath(gContainerFilePath));
	if (!reader) {
		throw std::invalid_argument(_Str("Path does not point to a recognised archive file: '", path, "'"));
	}
#if EPUB_USE(LIBXML2)
	_ocf = reader.xmlReadDocument(gContainerFilePath, nullptr, XML_PARSE_RECOVER|XML_PARSE_NOENT|XML_PARSE_DTDATTR);
#else
	decltype(_ocf) __tmp(reader.ReadDocument(gContainerFilePath, nullptr, /*RESOLVE_EXTERNALS*/ 1));
	_ocf = __tmp;
#endif
	if (!((bool)_ocf))
		return false;

#if EPUB_COMPILER_SUPPORTS(CXX_INITIALIZER_LISTS)
	XPathWrangler xpath(_ocf, { { "ocf", "urn:oasis:names:tc:opendocument:xmlns:container" } });
#else
	XPathWrangler::NamespaceList __ns;
	__ns["ocf"] = OCFNamespaceURI;
	XPathWrangler xpath(_ocf, __ns);
#endif
	xml::NodeSet nodes = xpath.Nodes(gRootfilesXPath);

	if (nodes.empty())
		return false;

	LoadEncryption();

	for (auto n : nodes)
	{
		string type = _getProp(n, "media-type");

		string path = _getProp(n, "full-path");
		if (path.empty())
			continue;

		auto pkg = Package::New(Ptr(), type);
		if (pkg->Open(path))
			_packages.push_back(pkg);
	}

    auto fm = FilterManager::Instance();
	for (auto& pkg : _packages)
	{
        auto fc = fm->BuildFilterChainForPackage(pkg);
		pkg->SetFilterChain(fc);
	}

	return true;
}
开发者ID:datalogics-bhaugen,项目名称:SDKLauncher-Windows,代码行数:58,代码来源:container.cpp

示例2: EPUB_COMPILER_SUPPORTS

string Package::PackageID() const
{
#if EPUB_COMPILER_SUPPORTS(CXX_INITIALIZER_LISTS)
    XPathWrangler xpath(_opf, {{"opf", OPFNamespace}, {"dc", DCNamespace}});
#else
    XPathWrangler::NamespaceList __m;
    __m["opf"] = OPFNamespace;
    __m["dc"] = DCNamespace;
    XPathWrangler xpath(_opf, __m);
#endif
    XPathWrangler::StringList strings = xpath.Strings("//*[@id=/opf:package/@unique-identifier]/text()");
    if ( strings.empty() )
        return string::EmptyString;
    return strings[0];
}
开发者ID:becka11y,项目名称:readium-sdk,代码行数:15,代码来源:package.cpp

示例3: xpath

void CLogContentFilter::readAllLogFilters(IPropertyTree* cfg)
{
    bool groupFilterRead = false;
    VStringBuffer xpath("Filters/Filter[@type='%s']", espLogContentGroupNames[ESPLCGBackEndResp]);
    IPropertyTree* filter = cfg->queryBranch(xpath.str());
    if (filter && filter->hasProp("@value"))
    {
        logBackEndResp = filter->getPropBool("@value");
        groupFilterRead = true;
    }

    xpath.setf("Filters/Filter[@type='%s']", espLogContentGroupNames[ESPLCGBackEndReq]);
    filter = cfg->queryBranch(xpath.str());
    if (filter && filter->hasProp("@value"))
    {
        logBackEndReq = filter->getPropBool("@value");
        groupFilterRead = true;
    }

    for (unsigned i = 0; i < ESPLCGBackEndReq; i++)
    {
        if (readLogFilters(cfg, i))
            groupFilterRead = true;
    }

    if (!groupFilterRead)
    {
        groupFilters.clear();
        readLogFilters(cfg, ESPLCGAll);
    }
}
开发者ID:Michael-Gardner,项目名称:HPCC-Platform,代码行数:31,代码来源:loggingagentbase.cpp

示例4: createElement

bool CPbl2XML::Convert(MSXML2::IXMLDOMElementPtr &library, _bstr_t &path)
{
	MSXML2::IXMLDOMElementPtr childnode = library->ownerDocument->
		createElement("childs");

	char buffer[256] = {0};

	int iResult = m_orca.LibraryDirectory((char *) path, 
		buffer, sizeof(buffer),	LibDir, (LPVOID) childnode.GetInterfacePtr());

	if(iResult != PBORCA_OK) {
		CString msg; msg.Format("FAILED: LibraryDirectory(...) : %s", (char *) path);
		log.write(msg);
		
		childnode = NULL;
		return false;
	}

	_bstr_t xpath("childs");
	MSXML2::IXMLDOMNodeListPtr childlist = library->selectNodes(xpath);

	if(childlist->length > 0) {
		library->replaceChild(childnode, childlist->item[0]);
	} else {
		library->appendChild(childnode);
	}

	// сохраняем значение комментария библиотеки
	library->setAttribute(_bstr_t("comment"), _bstr_t(buffer));

	return true;
}
开发者ID:vactorwu,项目名称:pbrebus,代码行数:32,代码来源:Pbl2XML.cpp

示例5: oDoc

/* long GetNodeUrlCount (in nsIDOMNode node); */
NS_IMETHODIMP nsDomAttUtil::GetNodeUrlCount(nsIDOMNode *node, PRInt32 *_retval )
{
     nsresult rv;
     nsCOMPtr<nsIXpathUtil> xpathUtil=do_CreateInstance("@nyapc.com/XPCOM/nsXpathUtil;1",&rv);
     if (NS_FAILED(rv))
     {
	  return rv;
     }
     nsCOMPtr<nsIDOMDocument> oDoc(nsnull);
     node->GetOwnerDocument(getter_AddRefs(oDoc));
     if(oDoc!=nsnull)
     {
	  xpathUtil->SetDocument(oDoc);
	  nsCOMPtr<nsISupportsArray> nodeArr(nsnull);
	  nsCString xpath(".//a[@href]");
	  xpathUtil->GetSubNodes(node,xpath,getter_AddRefs(nodeArr));
	  if(nodeArr!=nsnull)
	  {
	       PRUint32 arrlen=0;
	       nodeArr->Count(&arrlen);
	       *_retval=arrlen;
	  }else
	  {
	       *_retval=0;
	  }
     }else
     {
	  *_retval=0;
     }
     return NS_OK;
}
开发者ID:firememory,项目名称:dfwbi,代码行数:32,代码来源:nsDomAttUtil.cpp

示例6: wuid

WsWuInfo::WsWuInfo(const char *wuid_, const char *qset, const char *qname, const char *user, const char *pw) :
    wuid(wuid_), qsetname(qset), queryname(qname), username(user), password(pw)
{
    Owned<IWorkUnitFactory> wf = getWorkUnitFactory();
    if (!wuid.length() && qsetname.length() && queryname.length())
    {
        Owned<IPropertyTree> qstree = getQueryRegistry(qsetname.sget(), true);
        if (qstree)
        {
            VStringBuffer xpath("Query[@id=\"%s\"]", queryname.sget());
            IPropertyTree *query = qstree->queryPropTree(xpath.str());
            if (query)
                wuid.set(query->queryProp("@wuid"));
            else
                throw MakeStringException(-1, "Query %s not found in QuerySet %s", queryname.sget(), qsetname.sget());
        }
        else
            throw MakeStringException(-1, "QuerySet %s not found", qsetname.sget());
    }
        
    if (wuid.length())
    {
        wu.setown(wf->openWorkUnit(wuid.sget(), false));
        if (!wu)
            throw MakeStringException(-1, "Could not open workunit: %s", wuid.sget());
    }
    else
        throw MakeStringException(-1, "Workunit not specified");
}
开发者ID:hszander,项目名称:HPCC-Platform,代码行数:29,代码来源:wswuinfo.cpp

示例7: getPkgInfo

void getPkgInfo(const IPropertyTree *packageMaps, const char *target, const char *process, StringBuffer &info)
{
    Owned<IPropertyTree> tree = createPTree("PackageMaps");
    Owned<IPropertyTree> pkgSetRegistry = getPkgSetRegistry(process, true);
    if (!pkgSetRegistry)
    {
        toXML(tree, info);
        return;
    }
    StringBuffer xpath("PackageMap[@active='1']");
    if (target && *target)
        xpath.appendf("[@querySet='%s']", target);
    Owned<IPropertyTreeIterator> iter = pkgSetRegistry->getElements(xpath.str());
    ForEach(*iter)
    {
        IPropertyTree &item = iter->query();
        const char *id = item.queryProp("@id");
        if (id)
        {
            StringBuffer xpath;
            xpath.append("PackageMap[@id='").append(id).append("']");
            IPropertyTree *mapTree = packageMaps->queryPropTree(xpath);
            if (mapTree)
                mergePTree(tree, mapTree);
        }
    }

    toXML(tree, info);
}
开发者ID:ruidafu,项目名称:HPCC-Platform,代码行数:29,代码来源:ws_packageprocessService.cpp

示例8: querySDS

IPropertyTree *getPkgSetRegistry(const char *process, bool readonly)
{
    Owned<IRemoteConnection> globalLock = querySDS().connect("/PackageSets/", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SDS_LOCK_TIMEOUT);
    if (!globalLock)
        throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to connect to PackageSet information in dali /PackageSets");
    IPropertyTree *pkgSets = globalLock->queryRoot();
    if (!pkgSets)
        throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to open PackageSet information in dali /PackageSets");

    if (!process || !*process)
        process = "*";
    StringBuffer id;
    buildPkgSetId(id, process);

    //Only lock the branch for the target we're interested in.
    VStringBuffer xpath("/PackageSets/PackageSet[@id='%s']", id.str());
    Owned<IRemoteConnection> conn = querySDS().connect(xpath.str(), myProcessSession(), readonly ? RTM_LOCK_READ : RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT);
    if (!conn)
    {
        if (readonly)
            return NULL;

        Owned<IPropertyTree> pkgSet = createPTree();
        pkgSet->setProp("@id", id.str());
        pkgSet->setProp("@process", process);
        pkgSets->addPropTree("PackageSet", pkgSet.getClear());
        globalLock->commit();

        conn.setown(querySDS().connect(xpath.str(), myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT));
    }

    return (conn) ? conn->getRoot() : NULL;
}
开发者ID:ruidafu,项目名称:HPCC-Platform,代码行数:33,代码来源:ws_packageprocessService.cpp

示例9: doCreate

    void doCreate(const char *partname, const char *xml, unsigned updateFlags, StringArray &filesNotFound)
    {
        createPart(partname, xml);

        if (pmExisting)
        {
            if (!checkFlag(PKGADD_MAP_REPLACE))
                throw MakeStringException(PKG_NAME_EXISTS, "PackageMap %s already exists, either delete it or specify overwrite", pmid.str());
        }

        cloneDfsInfo(updateFlags, filesNotFound);

        if (pmExisting)
            packageMaps->removeTree(pmExisting);

        Owned<IPropertyTree> pmTree = createPTree("PackageMap", ipt_ordered);
        pmTree->setProp("@id", pmid);
        pmTree->setPropBool("@multipart", true);
        pmTree->addPropTree("Part", pmPart.getClear());
        packageMaps->addPropTree("PackageMap", pmTree.getClear());

        VStringBuffer xpath("PackageMap[@id='%s'][@querySet='%s']", pmid.str(), target.get());
        Owned<IPropertyTree> pkgSet = getPkgSetRegistry(process, false);
        IPropertyTree *psEntry = pkgSet->queryPropTree(xpath);

        if (!psEntry)
        {
            psEntry = pkgSet->addPropTree("PackageMap", createPTree("PackageMap"));
            psEntry->setProp("@id", pmid);
            psEntry->setProp("@querySet", target);
        }
        makePackageActive(pkgSet, psEntry, target, checkFlag(PKGADD_MAP_ACTIVATE));
    }
开发者ID:Josh-Googler,项目名称:HPCC-Platform,代码行数:33,代码来源:ws_packageprocessService.cpp

示例10: EPUB_COMPILER_SUPPORTS

string Container::Version() const
{
#if EPUB_COMPILER_SUPPORTS(CXX_INITIALIZER_LISTS)
    XPathWrangler xpath(_ocf, {{"ocf", "urn:oasis:names:tc:opendocument:xmlns:container"}});
#else
    XPathWrangler::NamespaceList __ns;
    __ns["ocf"] = OCFNamespaceURI;
    XPathWrangler xpath(_ocf, __ns);
#endif
    
    std::vector<string> strings = xpath.Strings(gVersionXPath);
    if ( strings.empty() )
        return "1.0";       // guess
    
    return std::move(strings[0]);
}
开发者ID:becka11y,项目名称:readium-sdk,代码行数:16,代码来源:container.cpp

示例11: _archive

Container::Container(const std::string& path) : _archive(Archive::Open(path))
{
    if ( _archive == nullptr )
        throw std::invalid_argument("Path does not point to a recognised archive file: '" + path + "'");

    // TODO: Initialize lazily? Doing so would make initialization faster, but require
    // PackageLocations() to become non-const, like Packages().
    ArchiveXmlReader reader(_archive->ReaderAtPath(gContainerFilePath));
    _ocf = reader.xmlReadDocument(gContainerFilePath, nullptr, XML_PARSE_RECOVER|XML_PARSE_NOENT|XML_PARSE_DTDATTR);
    if ( _ocf == nullptr )
        throw std::invalid_argument(std::string(__PRETTY_FUNCTION__) + ": No container.xml in " + path);

    XPathWrangler xpath(_ocf, {{"ocf", "urn:oasis:names:tc:opendocument:xmlns:container"}});
    xmlNodeSetPtr nodes = xpath.Nodes(reinterpret_cast<const xmlChar*>(gRootfilesXPath));

    if ( nodes == nullptr || nodes->nodeNr == 0 )
        throw std::invalid_argument(std::string(__PRETTY_FUNCTION__) + ": No rootfiles in " + path);

    for ( int i = 0; i < nodes->nodeNr; i++ )
    {
        xmlNodePtr n = nodes->nodeTab[i];

        const xmlChar * _type = xmlGetProp(n, reinterpret_cast<const xmlChar*>("media-type"));
        std::string type((_type == nullptr ? "" : reinterpret_cast<const char*>(_type)));

        const xmlChar * _path = xmlGetProp(n, reinterpret_cast<const xmlChar*>("full-path"));
        if ( _path == nullptr )
            continue;

        _packages.push_back(new Package(_archive, _path, type));
    }

    LoadEncryption();
}
开发者ID:jalal70,项目名称:readium-sdk,代码行数:34,代码来源:container.cpp

示例12: isScheduledWorkUnit

bool isScheduledWorkUnit(char const * wuid)
{
    Owned<IRemoteConnection> conn = querySDS().connect("/Schedule", myProcessSession(), RTM_LOCK_WRITE | RTM_CREATE_QUERY, connectionTimeout);
    StringBuffer xpath("*/*/*/");
    ncnameEscape(wuid, xpath);
    return conn->queryRoot()->hasProp(xpath.str());
}
开发者ID:AttilaVamos,项目名称:HPCC-Platform,代码行数:7,代码来源:schedulectrl.cpp

示例13: expandManifestDirectory

void expandManifestDirectory(IPropertyTree *manifestSrc, IPropertyTree &res, StringBuffer &dir, IDirectoryIterator *it, const char*mask, bool recursive)
{
    if (!it)
        return;
    ForEach(*it)
    {
        if (it->isDir())
        {
            if (recursive)
                expandManifestDirectory(manifestSrc, res, dir, it->query().directoryFiles(mask, false, true), mask, recursive);
            continue;
        }
        StringBuffer reldir;
        Owned<IPropertyTree> newRes = createPTreeFromIPT(&res);
        reldir.append(splitRelativePath(it->query().queryFilename(), dir, reldir));
        VStringBuffer xpath("Resource[@filename='%s']", reldir.str());
        if (manifestSrc->hasProp(xpath))
            continue;
        newRes->setProp("@filename", reldir.str());
        updateManifestResourcePaths(*newRes, dir.str());
        if (manifestSrc->hasProp(xpath.setf("resource[@resourcePath='%s']", newRes->queryProp("@resourcePath"))))
            continue;
        manifestSrc->addPropTree("Resource", newRes.getClear());
    }
}
开发者ID:hhy5277,项目名称:HPCC-Platform,代码行数:25,代码来源:hqlres.cpp

示例14: listPkgInfo

void listPkgInfo(double version, const char *target, const char *process, const IPropertyTree* packageMaps, IPropertyTree* pkgSetRegistry, IArrayOf<IConstPackageListMapData>* results)
{
    StringBuffer xpath("PackageMap");
    if (target && *target)
        xpath.appendf("[@querySet='%s']", target);
    Owned<IPropertyTreeIterator> iter = pkgSetRegistry->getElements(xpath.str());
    ForEach(*iter)
    {
        IPropertyTree &item = iter->query();
        const char *id = item.queryProp("@id");
        if (!id || !*id)
            continue;

        StringBuffer xpath;
        xpath.append("PackageMap[@id='").append(id).append("']");
        IPropertyTree *mapTree = packageMaps->queryPropTree(xpath);
        if (!mapTree)
            continue;

        Owned<IEspPackageListMapData> res = createPackageListMapData("", "");
        res->setActive(item.getPropBool("@active"));
        if (process && *process && (version >= 1.01))
            res->setProcess(process);
        getPackageListInfo(mapTree, res);
        if (target && *target)
            res->setTarget(target);
        else
            res->setTarget(item.queryProp("@querySet"));
        results->append(*res.getClear());
    }
}
开发者ID:ruidafu,项目名称:HPCC-Platform,代码行数:31,代码来源:ws_packageprocessService.cpp

示例15: makeAbsolutePath

bool ResourceManifest::loadInclude(IPropertyTree &include, const char *dir)
{
    const char *filename = include.queryProp("@filename");
    StringBuffer includePath;
    makeAbsolutePath(filename, dir, includePath);

    VStringBuffer xpath("Include[@originalFilename='%s']", includePath.str());
    if (manifest->hasProp(xpath.str()))
        return false;

    include.setProp("@originalFilename", includePath.str());
    StringBuffer includeDir;
    splitDirTail(includePath, includeDir);

    Owned<IPropertyTree> manifestInclude = createPTreeFromXMLFile(includePath.str());
    Owned<IPropertyTreeIterator> it = manifestInclude->getElements("*");
    ForEach(*it)
    {
        IPropertyTree &item = it->query();
        if (streq(item.queryName(), "Resource"))
            updateResourcePaths(item, includeDir.str());
        else if (streq(item.queryName(), "Include"))
        {
            if (!loadInclude(item, includeDir.str()))
                continue;
        }
        manifest->addPropTree(item.queryName(), LINK(&item));
    }
    return true;
}
开发者ID:Josh-Googler,项目名称:HPCC-Platform,代码行数:30,代码来源:hqlmanifest.cpp


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