1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
using System.IO;
|
21
|
|
using System.Xml;
|
22
|
|
using System.Web;
|
23
|
|
using System.Reflection;
|
24
|
|
using Seasar.Framework.Util;
|
25
|
|
|
26
|
|
namespace Seasar.Framework.Xml
|
27
|
|
{
|
28
|
|
|
29
|
|
|
30
|
|
|
31
|
|
public class S2XmlResolver : XmlResolver
|
32
|
|
{
|
33
|
|
public const string PUBLIC_ID = "-/SEASAR/DTD S2Container/EN";
|
34
|
|
public const string PUBLIC_ID21 = "-/SEASAR2.1/DTD S2Container/EN";
|
35
|
|
|
36
|
|
public const string COMPONENTS_URI = "http://www.seasar.org/dtd/components.dtd";
|
37
|
|
public const string COMPONENTS_URI21 = "http://www.seasar.org/dtd/components21.dtd";
|
38
|
|
|
39
|
|
public const string COMPONENTS_PATH = "components.dtd";
|
40
|
|
public const string COMPONENTS_PATH21 = "components21.dtd";
|
41
|
|
|
42
|
147
|
public S2XmlResolver()
|
43
|
|
{
|
44
|
|
}
|
45
|
|
|
46
|
140
|
public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
|
47
|
|
{
|
48
|
140
|
Stream stream = null;
|
49
|
|
|
50
|
140
|
string uri = HttpUtility.UrlDecode(absoluteUri.AbsoluteUri);
|
51
|
|
|
52
|
140
|
if(uri.EndsWith(PUBLIC_ID) || COMPONENTS_URI.Equals(uri))
|
53
|
|
{
|
54
|
18
|
stream = ResourceUtil.GetResourceAsStream(COMPONENTS_PATH, Assembly.GetExecutingAssembly());
|
55
|
|
}
|
56
|
122
|
else if(uri.EndsWith(PUBLIC_ID21) || COMPONENTS_URI21.Equals(uri))
|
57
|
|
{
|
58
|
122
|
stream = ResourceUtil.GetResourceAsStream(COMPONENTS_PATH21, Assembly.GetExecutingAssembly());
|
59
|
|
}
|
60
|
|
|
61
|
140
|
return stream;
|
62
|
|
}
|
63
|
|
|
64
|
0
|
public override System.Net.ICredentials Credentials
|
65
|
|
{
|
66
|
|
set
|
67
|
|
{
|
68
|
|
}
|
69
|
|
}
|
70
|
|
|
71
|
|
|
72
|
|
}
|
73
|
|
}
|
74
|
|
|