summaryrefslogtreecommitdiff
path: root/CIAO/tools/XML/XML_Schema_Resolver.tpp
blob: 22039e01f144050cf34eece35b9ab3e88343511c (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
// $Id$
#ifndef XML_SCHEMA_RESOLVER_TPP
#define XML_SCHEMA_RESOLVER_TPP

#include "XML/XML_Schema_Resolver.h"
#include "XML/XercesString.h"

#include <xercesc/framework/LocalFileInputSource.hpp>
#include <xercesc/framework/Wrapper4InputSource.hpp>

using xercesc::Wrapper4InputSource;
using xercesc::LocalFileInputSource;


namespace CIAO
{
  namespace XML
  {
    template<typename Resolver>
    XML_Schema_Resolver<Resolver>::XML_Schema_Resolver (void)
      : resolver_ ()
    {
    }

    template<typename Resolver>
    XML_Schema_Resolver<Resolver>::XML_Schema_Resolver (Resolver &res)
      : resolver_ (res)
    {
    }

    /// This function is called by the Xerces infrastructure to
    /// actually resolve the location of a schema.
    template<typename Resolver>
    InputSource *
    XML_Schema_Resolver<Resolver>::resolveEntity (const XMLCh *const publicId,
                                                    const XMLCh *const systemId)
    {
      XStr path = resolver_ (publicId, systemId);
      if (path.begin () == 0)
        return 0;
      
      // Ownership of these objects is given to other people.
      return /*new Wrapper4InputSource*/ (new LocalFileInputSource (path.begin ()));
    }    
  }
}

#endif /*XML_SCHEMA_RESOLVER_TPP*/