blob: a072df5e52958aeeecb2e2683258414a25933d59 (
plain) (
blame)
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
|
//
// EntityResolverImpl.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/EntityResolverImpl.h"
#include "Poco/SAX/InputSource.h"
#include "Poco/XML/XMLString.h"
#include "Poco/URI.h"
#include "Poco/Path.h"
#include "Poco/Exception.h"
using Poco::URIStreamOpener;
using Poco::URI;
using Poco::Path;
using Poco::Exception;
using Poco::IOException;
using Poco::OpenFileException;
namespace Poco {
namespace XML {
EntityResolverImpl::EntityResolverImpl():
_opener(URIStreamOpener::defaultOpener())
{
}
EntityResolverImpl::EntityResolverImpl(const URIStreamOpener& opener):
_opener(opener)
{
}
EntityResolverImpl::~EntityResolverImpl()
{
}
InputSource* EntityResolverImpl::resolveEntity(const XMLString* publicId, const XMLString& systemId)
{
std::istream* pIstr = resolveSystemId(systemId);
InputSource* pInputSource = new InputSource(systemId);
if (publicId) pInputSource->setPublicId(*publicId);
pInputSource->setByteStream(*pIstr);
return pInputSource;
}
void EntityResolverImpl::releaseInputSource(InputSource* pSource)
{
poco_check_ptr (pSource);
delete pSource->getByteStream();
delete pSource;
}
std::istream* EntityResolverImpl::resolveSystemId(const XMLString& systemId)
{
std::string sid = fromXMLString(systemId);
return _opener.open(sid);
}
} } // namespace Poco::XML
|