StandardRelaxNGProvider.java
3.75 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.xmp.path.XMPPath
*/
package com.adobe.xmp.schema.service;
import com.adobe.xmp.path.XMPPath;
import com.adobe.xmp.schema.service.RelaxNGProvider;
import com.adobe.xmp.schema.service.SchemaServiceException;
import com.adobe.xmp.schema.service.impl.SchemaManifestParser;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.namespace.QName;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class StandardRelaxNGProvider
implements RelaxNGProvider {
private static final String DEFAULT_MANIFEST_FILE = "relaxng/schemaManifest.xml";
private List<URI> includePaths;
private Map<String, URI> schemaMap;
public StandardRelaxNGProvider() throws SchemaServiceException {
this(null);
}
StandardRelaxNGProvider(URI schemaManifestURI) throws SchemaServiceException {
try {
if (schemaManifestURI == null) {
schemaManifestURI = StandardRelaxNGProvider.getResource("relaxng/schemaManifest.xml");
}
SchemaManifestParser.SchemaManifest manifest = SchemaManifestParser.parse(schemaManifestURI);
this.schemaMap = new HashMap<String, URI>();
for (String schemaURI : manifest.schemaFiles.keySet()) {
String path = manifest.schemaFiles.get(schemaURI);
this.schemaMap.put(schemaURI, StandardRelaxNGProvider.getResource(path));
}
this.includePaths = new ArrayList<URI>();
for (String includePath : manifest.includePaths) {
this.includePaths.add(StandardRelaxNGProvider.getResource(includePath));
}
}
catch (Exception e) {
throw new SchemaServiceException(e.getMessage(), e);
}
}
@Override
public InputStream getSchema(String namespaceURI) throws IOException {
URI filePath = this.schemaMap.get(namespaceURI);
if (filePath != null) {
URL url = filePath.toURL();
return url.openStream();
}
return null;
}
@Override
public InputStream getInclude(String includeName) throws IOException {
InputStream is;
is = null;
try {
for (URI path : this.includePaths) {
URI includePath = new URI(path + includeName);
URL url = includePath.toURL();
try {
is = url.openStream();
break;
}
catch (Exception e) {
continue;
}
}
}
catch (URISyntaxException e) {
throw new IOException(e.getMessage());
}
return is;
}
@Override
public boolean isAvailable(String namespaceURI) {
return this.schemaMap.containsKey(namespaceURI);
}
@Override
public Set<String> getNamespaces() {
return this.schemaMap.keySet();
}
private static ClassLoader getClassLoader() {
ClassLoader loader = StandardRelaxNGProvider.class.getClassLoader();
if (loader == null) {
loader = ClassLoader.getSystemClassLoader();
}
return loader;
}
private static URI getResource(String path) throws URISyntaxException {
ClassLoader loader = StandardRelaxNGProvider.getClassLoader();
return loader.getResource(path).toURI();
}
@Override
public Map<XMPPath, Map<QName, Map<String, String>>> getRuntimeDecorators() {
return null;
}
}