ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/SiteMapper/SiteMapper.cpp
(Generate patch)

Comparing SiteMapper/SiteMapper.cpp (file contents):
Revision 129 by Douglas Thrift, 2004-03-23T22:49:41-08:00 vs.
Revision 136 by Douglas Thrift, 2004-03-25T01:21:21-08:00

# Line 8 | Line 8
8   #include "Matcher.hpp"
9   #include "Page.hpp"
10  
11 #include <xalanc/Include/PlatformDefinitions.hpp>
12 #include <xercesc/util/PlatformUtils.hpp>
13 #include <xalanc/XPath/XPathEvaluator.hpp>
14
15 XALAN_USING_XERCES(XMLPlatformUtils)
16 XALAN_USING_XALAN(XPathEvaluator)
17
11   string program;
12   bool debug = false;
13  
14   int main(int argc, char* argv[])
15   {
16          program = argv[0];
17 <        
17 >
18          string siteIndex, siteMap;
19  
20 <        for (int index = 1; index < argc; argc++)
20 >        for (int index = 1; index < argc; index++)
21          {
22                  string arg(argv[index]);
23                  Matcher matcher;
# Line 37 | Line 30 | int main(int argc, char* argv[])
30                  {
31                          siteMap = matcher[1];
32                  }
33 +                else if (arg == "-D")
34 +                {
35 +                        if (!debug) debug = true;
36 +                }
37          }
38  
39          if (siteIndex != "" && siteMap != "")
40 <        {      
40 >        {
41                  XMLPlatformUtils::Initialize();
42                  XPathEvaluator::initialize();
43  
# Line 51 | Line 48 | int main(int argc, char* argv[])
48          }
49          else
50          {
51 <                cout << "Usage: " << program << " -index=index -map=map\n";
51 >                cout << "Usage: " << program << " -index=index -map=map [-D]\n";
52          }
53  
54          return 0;
# Line 59 | Line 56 | int main(int argc, char* argv[])
56  
57   SiteMapper::SiteMapper(const string& siteIndex, const string& siteMap)
58   {
59 +        oldMap(siteMap);
60 +        index(siteIndex);
61 +        newMap(siteMap);
62 + }
63 +
64 + void SiteMapper::oldMap(const string& siteMap)
65 + {
66 +        XalanSourceTreeInit init;
67 +        XalanSourceTreeDOMSupport support;
68 +        XalanSourceTreeParserLiaison liaison(support);
69 +
70 +        support.setParserLiaison(&liaison);
71 +
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;
78 +
79 +        XPathEvaluator evaluator;
80 +        XalanNode* list = evaluator.selectSingleNode(support, document,
81 +                XalanDOMString("/page/section/list").c_str());
82 +
83 +        if (list == 0) return;
84 +
85 +        oldMap(pages, evaluator, support, list);
86 + }
87 +
88 + void SiteMapper::oldMap(vector<Page>& pages, XPathEvaluator& evaluator,
89 +        XalanSourceTreeDOMSupport& support, XalanNode* list)
90 + {
91 +        NodeRefList nodes = evaluator.selectNodeList(support, list,
92 +                XalanDOMString("item").c_str());
93 +
94 +
95 +        for (int index = 0; index < nodes.getLength(); index++)
96 +        {
97 +                XalanNode* node = nodes.item(index);
98 +
99 +                cerr << "node=" << node << '\n';
100 +
101 +                ostringstream url, title;
102 +
103 +                {
104 +                        XObjectPtr address = evaluator.evaluate(support, node,
105 +                                XalanDOMString("link/@address").c_str());
106 +
107 +                        if (!address.null())
108 +                        {
109 +                                url << address->str();
110 +                                cerr << "url=" << url.str() << '\n';
111 +                        }
112 +                }
113 +
114 +                {
115 +                        XObjectPtr link = evaluator.evaluate(support, node,
116 +                                XalanDOMString("link").c_str());
117 +
118 +                        if (!link.null())
119 +                        {
120 +                                title << link->str();
121 +                                cerr << "title=" << title.str() << '\n';
122 +                        }
123 +                }
124 +
125 +                Page page(url.str(), title.str());
126 +                if (title.str() == "Contact") cerr << node << '\n';
127 +                XalanNode* list = evaluator.selectSingleNode(support, node,
128 +                        XalanDOMString("list").c_str());
129 +
130 +                cerr << "list=" << list << '\n';
131 +
132 +                if (list != 0) oldMap(page.getChildren(), evaluator, support, list);
133 +
134 +                pages.push_back(page);
135 +        }
136 + }
137 +
138 + void SiteMapper::index(const string& siteIndex)
139 + {
140          //
141   }
142 +
143 + void SiteMapper::newMap(const string& siteMap)
144 + {
145 +        //
146 +
147 +        for (int index = 0; index < pages.size(); index++)
148 +        {
149 +                cout << pages[index] << '\n';
150 +        }
151 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines