blob: 28e916a047d11bf6f57cd73d32a920a076222d3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#include "XML_Schema_Resolver.h"
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XercesDefs.hpp>
#include "XercesString.h"
#include "ace/Env_Value_T.h"
#include "ace/SString.h"
#include <iostream>
namespace XML
{
Basic_Resolver::Basic_Resolver (const ACE_TCHAR *path)
: path_ (path)
{
}
XMLCh *
Basic_Resolver::operator() (const XMLCh *const,
const XMLCh *const systemId) const
{
XStr path (path_);
path.append (systemId);
return path.release ();
}
Environment_Resolver::Environment_Resolver (const ACE_TCHAR *variable,
const ACE_TCHAR *relpath)
{
this->add_path (variable, relpath);
}
using xercesc::XMLPlatformUtils;
void
Environment_Resolver::add_path (const ACE_TCHAR *variable,
const ACE_TCHAR *relpath)
{
ACE_Env_Value <ACE_TString> path_env (variable,
ACE_TEXT(""));
XStr xpath (static_cast<ACE_TString>(path_env).c_str());
XStr xrelpath (relpath);
xpath.append (xrelpath);
paths_.push_back (xpath);
}
XMLCh *
Environment_Resolver::operator() (const XMLCh *const,
const XMLCh *const systemId) const
{
for (std::vector<XStr>::const_iterator i = this->paths_.begin ();
i != this->paths_.end ();
++i)
{
XStr path (*i);
path.append(systemId);
FileHandle file (XMLPlatformUtils::openFile (path));
if (file != 0)
{
XMLPlatformUtils::closeFile (file);
return path.release ();
}
}
return 0;
}
}
|