本文整理汇总了C++中PXmlTok::GetSubTok方法的典型用法代码示例。如果您正苦于以下问题:C++ PXmlTok::GetSubTok方法的具体用法?C++ PXmlTok::GetSubTok怎么用?C++ PXmlTok::GetSubTok使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PXmlTok
的用法示例。
在下文中一共展示了PXmlTok::GetSubTok方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddHits
void TDzsHKwBs::AddHits(const PXmlTok& TopicTok, const PBook& Book){
IAssert(TopicTok->IsTag("topic"));
// execute query & add hits
if (TopicTok->IsSubTag("query")){
// get query string
TStr QueryStr=TopicTok->GetTagTok("query")->GetTokStr(false);
// search
PBixRes BixRes=Book->Search(QueryStr);
if (BixRes->IsOk()){
printf("%s - %d\n", QueryStr.CStr(), BixRes->GetHits());
int Hits=BixRes->GetHits();
// retrieve or create <refs> subtag
PXmlTok RefsTok;
if (Hits>0){
if (TopicTok->IsSubTag("refs")){
RefsTok=TopicTok->GetTagTok("refs");
} else {
RefsTok=TXmlTok::New(xsyTag, "refs");
TopicTok->AddSubTok(RefsTok);
}
}
// add hits
for (int HitN=0; HitN<Hits; HitN++){
// get hit info
TStr SecIdStr; TStr TitleStr; TStr SecStr; TStr CtxStr;
BixRes->GetHitInfo(
Book, HitN, -1, 100, SecIdStr, TitleStr, SecStr, CtxStr);
TStr TitleXmlStr=TXmlLx::GetXmlFromPlainStr(TitleStr);
TStr UrlXmlStr=TXmlLx::GetXmlFromPlainStr(SecIdStr);
// create <ref>
PXmlTok RefTok=TXmlTok::New(xsyTag, "ref");
//RefTok->AddArg("title", TitleXmlStr);
RefsTok->AddSubTok(RefTok);
// create <title>
PXmlTok TitleTok=TXmlTok::New(xsyTag, "title");
RefTok->AddSubTok(TitleTok);
PXmlTok TitleStrTok=TXmlTok::New(xsyStr, TitleXmlStr);
TitleTok->AddSubTok(TitleStrTok);
// create <url>
PXmlTok UrlTok=TXmlTok::New(xsyTag, "url");
RefTok->AddSubTok(UrlTok);
PXmlTok UrlStrTok=TXmlTok::New(xsyStr, UrlXmlStr);
UrlTok->AddSubTok(UrlStrTok);
}
}
}
// recurse
for (int SubTokN=0; SubTokN<TopicTok->GetSubToks(); SubTokN++){
PXmlTok CurTok=TopicTok->GetSubTok(SubTokN);
if (CurTok->IsTag("topic")){
AddHits(CurTok, Book);
}
}
}
示例2: IsTopicOk
/////////////////////////////////////////////////
// Dzs-Hierarchical-Keyword-Base
bool TDzsHKwBs::IsTopicOk(const PXmlTok& TopicTok){
// <topic> is expected
if (!TopicTok->IsTag("topic")){return false;}
// <title> is mandatory subtag
if (!TopicTok->IsSubTag("title")){return false;}
// recurse
for (int SubTokN=0; SubTokN<TopicTok->GetSubToks(); SubTokN++){
PXmlTok CurTok=TopicTok->GetSubTok(SubTokN);
if (CurTok->IsTag("topic")){
if (!IsTopicOk(CurTok)){return false;}
}
}
return true;
}
示例3: AddDataTokToChA
/////////////////////////////////////////////////
// Dzs-Base-Document
void TDzsBsDoc::AddDataTokToChA(const PXmlTok& Tok, TChA& ChA){
switch (Tok->GetSym()){
case xsyWs:
case xsyStr:
case xsyQStr:
ChA+=Tok->GetStr(); break;
case xsyTag:{
TStr TagNm=Tok->GetStr();
if ((TagNm=="GUID")||(TagNm=="REFF")||(TagNm=="TYPE")||(TagNm=="FILE")){break;}
if ((TagNm=="TITLE")||(TagNm=="TOPICTITLE")){break;}
ChA+=' ';
if ((TagNm=="TITLE")||(TagNm=="TOPICTITLE")){ChA+="<TITLE>";}
for (int SubTokN=0; SubTokN<Tok->GetSubToks(); SubTokN++){
AddDataTokToChA(Tok->GetSubTok(SubTokN), ChA);}
if ((TagNm=="TITLE")||(TagNm=="TOPICTITLE")){ChA+="</TITLE>";}
ChA+=' '; break;}
default: Fail;
}
}
示例4: SaveHtml
void TDzsHKwBs::SaveHtml(const PXmlTok& TopicTok, const TStr& FPath){
TStr NrFPath=TStr::GetNrFPath(FPath);
TStr TitleStr=TopicTok->GetTagTok("title")->GetTokStr(false);
TStr FPathSeg=GetFPathSegStr(TitleStr);
printf("%s\n", TitleStr.CStr());
TDir::GenDir(NrFPath+FPathSeg);
PSOut SOut=TFOut::New(NrFPath+FPathSeg+"/"+"default.htm");
SOut->PutStr("<html>"); SOut->PutDosLn();
SOut->PutDosLn();
// head
SOut->PutStr("<head>"); SOut->PutDosLn();
SOut->PutStr("<title>"); SOut->PutStr(TitleStr); SOut->PutStr("</title>"); SOut->PutDosLn();
SOut->PutStr("</head>"); SOut->PutDosLn();
SOut->PutDosLn();
// body-start
SOut->PutStr("<body>"); SOut->PutDosLn();
SOut->PutStr("<center><h3>");
SOut->PutStr(TitleStr);
SOut->PutStr("</h3></center"); SOut->PutDosLn();
// subtrees
SOut->PutStr("<ul>"); SOut->PutDosLn();
for (int SubTokN=0; SubTokN<TopicTok->GetSubToks(); SubTokN++){
PXmlTok CurTok=TopicTok->GetSubTok(SubTokN);
if (CurTok->IsTag("topic")){
TStr SubTitleStr=CurTok->GetTagTok("title")->GetTokStr(false);
TStr SubFPathSeg=GetFPathSegStr(SubTitleStr);
SOut->PutStr("<li>");
SOut->PutStr(TStr("<a href=\"")+SubFPathSeg+"/\">");
SOut->PutStr("<b>"); SOut->PutStr(SubTitleStr); SOut->PutStr("</b>");
SOut->PutStr("</a>");
SOut->PutStr("</li>"); SOut->PutDosLn();
SaveHtml(CurTok, NrFPath+FPathSeg);
}
}
SOut->PutStr("</ul>"); SOut->PutDosLn();
// references
if (TopicTok->IsSubTag("refs")){
SOut->PutDosLn(); SOut->PutStr("<hr>"); SOut->PutDosLn(); SOut->PutDosLn();
PXmlTok RefsTok=TopicTok->GetTagTok("refs");
SOut->PutStr("<ul>"); SOut->PutDosLn();
for (int RefTokN=0; RefTokN<RefsTok->GetSubToks(); RefTokN++){
// get <ref> data
PXmlTok RefTok=RefsTok->GetSubTok(RefTokN);
TStr RefTitleStr=RefTok->GetTagTok("title")->GetTokStr(false);
TStr RefUrlStr=RefTok->GetTagTok("url")->GetTokStr(false);
// generate <li>
SOut->PutStr("<li>");
SOut->PutStr(TStr("<a href=\"")+RefUrlStr+"\">");
SOut->PutStr(RefTitleStr);
SOut->PutStr("</a>");
SOut->PutStr("</li>"); SOut->PutDosLn();
}
SOut->PutStr("</ul>"); SOut->PutDosLn();
}
// footer
SOut->PutStr("<center>"); SOut->PutDosLn();
SOut->PutStr("<small>");
SOut->PutStr("Copyright DZS");
SOut->PutStr("</small>"); SOut->PutDosLn();
SOut->PutStr("</center>"); SOut->PutDosLn();
// body-end
SOut->PutStr("</body>"); SOut->PutDosLn();
SOut->PutStr("</html>"); SOut->PutDosLn();
}