1 |
// Site Mapper |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#include "SiteMapper.hpp" |
8 |
#include "Matcher.hpp" |
9 |
#include "Page.hpp" |
10 |
|
11 |
#include <xalanc/Include/PlatformDefinitions.hpp> |
12 |
#include <xercesc/util/PlatformUtils.hpp> |
13 |
#include <xercesc/framework/LocalFileInputSource.hpp> |
14 |
#include <xalanc/XPath/XObject.hpp> |
15 |
#include <xalanc/XPath/XPathEvaluator.hpp> |
16 |
#include <xalanc/DOMSupport/XalanDocumentPrefixResolver.hpp> |
17 |
#include <xalanc/XalanSourceTree/XalanSourceTreeDOMSupport.hpp> |
18 |
#include <xalanc/XalanSourceTree/XalanSourceTreeInit.hpp> |
19 |
#include <xalanc/XalanSourceTree/XalanSourceTreeParserLiaison.hpp> |
20 |
|
21 |
XALAN_USING_XERCES(XMLPlatformUtils) |
22 |
XALAN_USING_XERCES(LocalFileInputSource) |
23 |
XALAN_USING_XALAN(XObjectPtr) |
24 |
XALAN_USING_XALAN(XPathEvaluator) |
25 |
XALAN_USING_XALAN(XalanDocument) |
26 |
XALAN_USING_XALAN(XalanDocumentPrefixResolver) |
27 |
XALAN_USING_XALAN(XalanDOMString) |
28 |
XALAN_USING_XALAN(XalanNode) |
29 |
XALAN_USING_XALAN(XalanSourceTreeInit) |
30 |
XALAN_USING_XALAN(XalanSourceTreeDOMSupport) |
31 |
XALAN_USING_XALAN(XalanSourceTreeParserLiaison) |
32 |
|
33 |
string program; |
34 |
bool debug = false; |
35 |
|
36 |
int main(int argc, char* argv[]) |
37 |
{ |
38 |
program = argv[0]; |
39 |
|
40 |
string siteIndex, siteMap; |
41 |
|
42 |
for (int index = 1; index < argc; index++) |
43 |
{ |
44 |
string arg(argv[index]); |
45 |
Matcher matcher; |
46 |
|
47 |
if (arg == matcher("^-index=(.*)$")) |
48 |
{ |
49 |
siteIndex = matcher[1]; |
50 |
} |
51 |
else if (arg == matcher("^-map=(.*)$")) |
52 |
{ |
53 |
siteMap = matcher[1]; |
54 |
} |
55 |
else if (arg == "-D") |
56 |
{ |
57 |
if (!debug) debug = true; |
58 |
} |
59 |
} |
60 |
|
61 |
if (siteIndex != "" && siteMap != "") |
62 |
{ |
63 |
XMLPlatformUtils::Initialize(); |
64 |
XPathEvaluator::initialize(); |
65 |
|
66 |
SiteMapper mapper(siteIndex, siteMap); |
67 |
|
68 |
XPathEvaluator::terminate(); |
69 |
XMLPlatformUtils::Terminate(); |
70 |
} |
71 |
else |
72 |
{ |
73 |
cout << "Usage: " << program << " -index=index -map=map [-D]\n"; |
74 |
} |
75 |
|
76 |
return 0; |
77 |
} |
78 |
|
79 |
SiteMapper::SiteMapper(const string& siteIndex, const string& siteMap) |
80 |
{ |
81 |
XalanSourceTreeInit init; |
82 |
|
83 |
oldMap(siteMap); |
84 |
index(siteIndex); |
85 |
newMap(siteMap); |
86 |
} |
87 |
|
88 |
void SiteMapper::oldMap(const string& siteMap) |
89 |
{ |
90 |
XalanSourceTreeDOMSupport support; |
91 |
XalanSourceTreeParserLiaison liaison(support); |
92 |
|
93 |
support.setParserLiaison(&liaison); |
94 |
|
95 |
XalanDOMString file(siteMap.c_str()); |
96 |
LocalFileInputSource source(file.c_str()); |
97 |
|
98 |
XalanDocument* document = liaison.parseXMLStream(source); |
99 |
|
100 |
if (document == 0) return; |
101 |
|
102 |
XPathEvaluator evaluator; |
103 |
XalanNode* list = evaluator.selectSingleNode(support, document, |
104 |
XalanDOMString("/page/section/list").c_str()); |
105 |
|
106 |
if (list == 0) return; |
107 |
} |
108 |
|
109 |
void SiteMapper::index(const string& siteIndex) |
110 |
{ |
111 |
// |
112 |
} |
113 |
|
114 |
void SiteMapper::newMap(const string& siteMap) |
115 |
{ |
116 |
// |
117 |
} |