blob: 1826c8c1af6be74b81e136c67246bb8fcec2ac5f (
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/**
* @file XML_Schema_Resolver.h
* @author Will Otte <wotte@dre.vanderbilt.edu>
*
* $Id$
*
* Resolves schema locations.
*/
#ifndef CIAO_XML_SCHEMA_RESOLVER_H
#define CIAO_XML_SCHEMA_RESOLVER_H
#include /**/ "ace/pre.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "XML/CIAO_XML_Utils_Export.h"
#include "XML/XercesString.h"
#include <xercesc/sax/EntityResolver.hpp>
#include <vector>
#include <string>
using namespace xercesc;
namespace CIAO
{
namespace XML
{
// forward decl.
struct NoOp_Resolver;
/**
* @class CIAO_Schema_Resolver
* @brief Resolves schema locations for CIAO.
*
* Template argument Resolver should be a functor with an operation
* const ACE_TCHAR * operator () (...arguments from resolveEntity...)
*/
template <typename Resolver = NoOp_Resolver>
class XML_Schema_Resolver
: public virtual EntityResolver
{
public:
XML_Schema_Resolver (void);
XML_Schema_Resolver (Resolver &resolver);
/// This function is called by the Xerces infrastructure to
/// actually resolve the location of a schema.
virtual InputSource * resolveEntity (const XMLCh *const publicId,
const XMLCh *const systemId);
private:
XML_Schema_Resolver (XML_Schema_Resolver<Resolver> &);
Resolver &resolver_;
};
/**
* @class NoOp_Resolver
* @brief Resolver that does nothing.
*/
struct NoOp_Resolver
{
const XMLCh* operator() (const XMLCh *const,
const XMLCh *const systemId) const
{ return systemId; };
};
/**
* @class Basic_Resolver
* @brief Resolves a schema location from a fixed path.
*/
struct Basic_Resolver
{
Basic_Resolver (const ACE_TCHAR *path);
XMLCh* operator() (const XMLCh *const publicId,
const XMLCh *const systemId) const;
XStr path_;
};
/**
* @class Environment_Resolver
* @brief Resolves a schema location from a path from an environment variable.
*/
struct CIAO_XML_Utils_Export Environment_Resolver
{
Environment_Resolver (const ACE_TCHAR *variable = ACE_TEXT(""),
const ACE_TCHAR *path = ACE_TEXT("./"));
void add_path (const ACE_TCHAR *variable,
const ACE_TCHAR *path);
XMLCh* operator() (const XMLCh *const publicId,
const XMLCh *const systemId) const;
std::vector<XStr> paths_;
};
}
}
#include "XML/XML_Schema_Resolver.tpp"
#include /**/ "ace/post.h"
#endif /* CIAO_XML_SCHEMA_RESOLVER_H */
|