diff options
Diffstat (limited to 'CIAO/tools/Config_Handlers/Utils/XML_Schema_Resolver.cpp')
-rw-r--r-- | CIAO/tools/Config_Handlers/Utils/XML_Schema_Resolver.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/CIAO/tools/Config_Handlers/Utils/XML_Schema_Resolver.cpp b/CIAO/tools/Config_Handlers/Utils/XML_Schema_Resolver.cpp new file mode 100644 index 00000000000..269e95ab425 --- /dev/null +++ b/CIAO/tools/Config_Handlers/Utils/XML_Schema_Resolver.cpp @@ -0,0 +1,55 @@ +// $Id$ +#include "XML_Schema_Resolver.h" +#include "XercesString.h" +#include "ace/Env_Value_T.h" +#include <xercesc/framework/LocalFileInputSource.hpp> +#include <xercesc/framework/Wrapper4InputSource.hpp> + +using xercesc::Wrapper4InputSource; +using xercesc::LocalFileInputSource; + + +namespace CIAO +{ + namespace Config_Handlers + { + CIAO_Schema_Resolver::CIAO_Schema_Resolver (void) + { + this->base_path_ = this->resolve_from_environment (); + } + + CIAO_Schema_Resolver::CIAO_Schema_Resolver (const char *path) + { + if (path == 0) + this->base_path_ = this->resolve_from_environment (); + else + this->base_path_ = path; + } + + /// This function is called by the Xerces infrastructure to + /// actually resolve the location of a schema. + DOMInputSource * + CIAO_Schema_Resolver::resolveEntity (const XMLCh *const publicId, + const XMLCh *const systemId, + const XMLCh *const baseURI) + { + ACE_UNUSED_ARG (baseURI); + ACE_UNUSED_ARG (publicId); + + XStr path (this->base_path_.c_str ()); + path.append (systemId); + + // Ownership of these objects is given to other people. + return new Wrapper4InputSource (new LocalFileInputSource (path)); + } + + std::string + CIAO_Schema_Resolver::resolve_from_environment (void) + { + ACE_Env_Value <const char *> path ("CIAO_ROOT", ""); + + std::string retval (path); + return retval += "/docs/schema/"; + } + } +} |