42 |
|
|
43 |
|
if (siteIndex != "" && siteMap != "") |
44 |
|
{ |
45 |
– |
XMLPlatformUtils::Initialize(); |
46 |
– |
XPathEvaluator::initialize(); |
47 |
– |
|
45 |
|
SiteMapper mapper(siteIndex, siteMap); |
49 |
– |
|
50 |
– |
XPathEvaluator::terminate(); |
51 |
– |
XMLPlatformUtils::Terminate(); |
46 |
|
} |
47 |
|
else |
48 |
|
{ |
61 |
|
|
62 |
|
void SiteMapper::oldMap(const string& siteMap) |
63 |
|
{ |
64 |
< |
support.setParserLiaison(&liaison); |
65 |
< |
|
72 |
< |
XalanDOMString file(siteMap.c_str()); |
73 |
< |
LocalFileInputSource source(file.c_str()); |
74 |
< |
|
75 |
< |
XalanDocument* document = liaison.parseXMLStream(source); |
76 |
< |
|
77 |
< |
if (document == 0) return; |
64 |
> |
ext::Handle<xml::Document> document(xml::Parse(siteMap)); |
65 |
> |
ext::Handle<xml::Node> list(*document/"page"/"section"/"list"); |
66 |
|
|
67 |
< |
XalanNode* list = evaluator.selectSingleNode(support, document, |
80 |
< |
XalanDOMString("/page/section/list").c_str()); |
81 |
< |
|
82 |
< |
if (list == 0) return; |
83 |
< |
|
84 |
< |
comment << evaluator.evaluate(support, document, |
85 |
< |
XalanDOMString("comment()").c_str())->str(); |
86 |
< |
|
87 |
< |
item = evaluator.createXPath(XalanDOMString("item").c_str()); |
88 |
< |
address = evaluator.createXPath(XalanDOMString("link/@address").c_str()); |
89 |
< |
link = evaluator.createXPath(XalanDOMString("link").c_str()); |
90 |
< |
this->list = evaluator.createXPath(XalanDOMString("list").c_str()); |
67 |
> |
comment = *document/"comment()"; |
68 |
|
|
69 |
|
oldMap(pages, list); |
93 |
– |
|
94 |
– |
evaluator.destroyXPath(item); |
95 |
– |
evaluator.destroyXPath(address); |
96 |
– |
evaluator.destroyXPath(link); |
97 |
– |
evaluator.destroyXPath(this->list); |
70 |
|
} |
71 |
|
|
72 |
< |
void SiteMapper::oldMap(vector<Page>& pages, XalanNode* list) |
72 |
> |
void SiteMapper::oldMap(vector<Page>& pages, xml::Node* list) |
73 |
|
{ |
74 |
< |
NodeRefList nodes = evaluator.selectNodeList(support, list, *item); |
74 |
> |
xml::NodeSet nodes(*list/"item"); |
75 |
|
|
76 |
< |
for (int index(0); index < nodes.getLength(); ++index) |
76 |
> |
for (xml::NodeSet::Iterator node(nodes.Begin()); node != nodes.End(); |
77 |
> |
++node) |
78 |
|
{ |
79 |
< |
XalanNode* node = nodes.item(index); |
80 |
< |
ostringstream url, title; |
81 |
< |
|
109 |
< |
url << evaluator.evaluate(support, node, *address)->str(); |
110 |
< |
title << evaluator.evaluate(support, node, *link)->str(); |
79 |
> |
string url(**node/"link"/"@address"), title(**node/"link"); |
80 |
> |
Page page(url, title); |
81 |
> |
ext::Handle<xml::Node> list(**node/"list"); |
82 |
|
|
83 |
< |
Page page(url.str(), title.str()); |
113 |
< |
XalanNode* list = evaluator.selectSingleNode(support, node, |
114 |
< |
*(this->list)); |
115 |
< |
|
116 |
< |
if (list != 0) oldMap(page.getChildren(), list); |
83 |
> |
if (!list.IsEmpty()) oldMap(page.getChildren(), list); |
84 |
|
|
85 |
|
pages.push_back(page); |
86 |
|
} |
88 |
|
|
89 |
|
void SiteMapper::newIndex(const string& siteIndex) |
90 |
|
{ |
91 |
< |
XalanDOMString file(siteIndex.c_str()); |
92 |
< |
LocalFileInputSource source(file.c_str()); |
126 |
< |
|
127 |
< |
XalanDocument* document = liaison.parseXMLStream(source); |
128 |
< |
|
129 |
< |
if (document == 0) return; |
130 |
< |
|
131 |
< |
address = evaluator.createXPath(XalanDOMString("address").c_str()); |
132 |
< |
port = evaluator.createXPath(XalanDOMString("port").c_str()); |
133 |
< |
path = evaluator.createXPath(XalanDOMString("path").c_str()); |
134 |
< |
title = evaluator.createXPath(XalanDOMString("title").c_str()); |
135 |
< |
|
136 |
< |
NodeRefList nodes = evaluator.selectNodeList(support, document, |
137 |
< |
XalanDOMString("/index/page").c_str()); |
91 |
> |
ext::Handle<xml::Document> document(xml::Parse(siteIndex)); |
92 |
> |
xml::NodeSet nodes(*document/"index"/"page"); |
93 |
|
|
94 |
< |
for (int index(0); index < nodes.getLength(); ++index) |
94 |
> |
for (xml::NodeSet::Iterator node(nodes.Begin()); node != nodes.End(); |
95 |
> |
++node) |
96 |
|
{ |
97 |
< |
XalanNode* node = nodes.item(index); |
98 |
< |
ostringstream address; |
97 |
> |
string address(**node/"address"); |
98 |
> |
string port(**node/"port"); |
99 |
|
|
100 |
< |
address << evaluator.evaluate(support, node, *(this->address))->str(); |
145 |
< |
|
146 |
< |
double port = evaluator.evaluate(support, node, *(this->port))->num(); |
147 |
< |
|
148 |
< |
if (port >= 0 && port <= 65535) |
100 |
> |
if (!port.empty()) |
101 |
|
{ |
102 |
< |
address << ':' << int(port); |
102 |
> |
address += ':' + port; |
103 |
|
} |
104 |
|
|
105 |
< |
ostringstream path, title; |
106 |
< |
|
155 |
< |
path << evaluator.evaluate(support, node, *(this->path))->str(); |
156 |
< |
title << evaluator.evaluate(support, node, *(this->title))->str(); |
157 |
< |
|
158 |
< |
Page page(address.str(), path.str(), title.str()); |
105 |
> |
string path(**node/"path"), title(**node/"title"); |
106 |
> |
Page page(address, path, title); |
107 |
|
Matcher matcher; |
108 |
|
|
109 |
|
if (page == matcher(string("^Douglas\\sThrift's\\sWebsite\\s\\|\\sDou") |
131 |
|
>(page.getAddress(), items)).first->second.insert(pair<string, |
132 |
|
Page>(page.getChildOf(), page)); |
133 |
|
} |
186 |
– |
|
187 |
– |
evaluator.destroyXPath(address); |
188 |
– |
evaluator.destroyXPath(port); |
189 |
– |
evaluator.destroyXPath(path); |
190 |
– |
evaluator.destroyXPath(title); |
134 |
|
} |
135 |
|
|
136 |
|
bool SiteMapper::newIndex(vector<Page>& pages, Page& page) |
175 |
|
<< "<?xml-stylesheet type=\"text/xsl\" href=\"stylesheets/sitemap.xsl" |
176 |
|
<< "\"?>\n" |
177 |
|
<< "<!DOCTYPE page SYSTEM \"stylesheets/page.dtd\">\n" |
178 |
< |
<< "<!--" << comment.str() << "-->\n" |
178 |
> |
<< "<!--" << comment << "-->\n" |
179 |
|
<< "<page>\n" |
180 |
|
<< "\t<title>Sitemap</title>\n" |
181 |
|
<< "\t<section>\n" |