1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package org.qedeq.kernel.xml.parser; |
19 |
| |
20 |
| import java.io.FileNotFoundException; |
21 |
| import java.io.InputStream; |
22 |
| |
23 |
| import org.qedeq.kernel.context.KernelContext; |
24 |
| import org.qedeq.kernel.log.Trace; |
25 |
| import org.xml.sax.EntityResolver; |
26 |
| import org.xml.sax.InputSource; |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| public final class SaxEntityResolver implements EntityResolver { |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
216
| public InputSource resolveEntity(final String publicId, final String systemId)
|
41 |
| throws FileNotFoundException { |
42 |
216
| final String method = "resolveEntity";
|
43 |
216
| Trace.param(this, method, "systemId", systemId);
|
44 |
216
| Trace.param(this, method, "publicId", publicId);
|
45 |
216
| if ((systemId == null)) {
|
46 |
0
| return null;
|
47 |
| } |
48 |
216
| if (systemId.equals("http://www.qedeq.org/" + KernelContext.getKernelVersionDirectory()
|
49 |
| + "/xml/qedeq.xsd")) { |
50 |
54
| InputStream in = SaxEntityResolver.class.getResourceAsStream(
|
51 |
| "/org/qedeq/kernel/xml/schema/qedeq.xsd"); |
52 |
54
| if (in == null) {
|
53 |
0
| throw new FileNotFoundException("/org/qedeq/kernel/xml/schema/qedeq.xsd");
|
54 |
| } |
55 |
54
| InputSource inputSource = new InputSource(in);
|
56 |
54
| inputSource.setPublicId(publicId);
|
57 |
54
| inputSource.setSystemId(systemId);
|
58 |
54
| return inputSource;
|
59 |
162
| } else if (systemId.equals("http://www.qedeq.org/"
|
60 |
| + KernelContext.getKernelVersionDirectory() |
61 |
| + "/xml/parser.xsd")) { |
62 |
162
| InputStream in = SaxEntityResolver.class.getResourceAsStream(
|
63 |
| "/org/qedeq/kernel/xml/schema/parser.xsd"); |
64 |
162
| if (in == null) {
|
65 |
0
| throw new FileNotFoundException("/org/qedeq/kernel/xml/schema/parser.xsd");
|
66 |
| } |
67 |
162
| InputSource inputSource = new InputSource(in);
|
68 |
162
| inputSource.setPublicId(publicId);
|
69 |
162
| inputSource.setSystemId(systemId);
|
70 |
162
| return inputSource;
|
71 |
| } |
72 |
| |
73 |
| |
74 |
0
| Trace.trace(this, method, "unknown entity");
|
75 |
0
| return null;
|
76 |
| } |
77 |
| } |