summaryrefslogtreecommitdiff
path: root/modules/CIAO/tools/XML/XML_Schema_Resolver.h
diff options
context:
space:
mode:
Diffstat (limited to 'modules/CIAO/tools/XML/XML_Schema_Resolver.h')
-rw-r--r--modules/CIAO/tools/XML/XML_Schema_Resolver.h109
1 files changed, 109 insertions, 0 deletions
diff --git a/modules/CIAO/tools/XML/XML_Schema_Resolver.h b/modules/CIAO/tools/XML/XML_Schema_Resolver.h
new file mode 100644
index 00000000000..1826c8c1af6
--- /dev/null
+++ b/modules/CIAO/tools/XML/XML_Schema_Resolver.h
@@ -0,0 +1,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 */