equal
deleted
inserted
replaced
50 } |
50 } |
51 |
51 |
52 @Override |
52 @Override |
53 public InputSource resolveEntity(String publicId, String systemId) { |
53 public InputSource resolveEntity(String publicId, String systemId) { |
54 //Normalize publicId and systemId |
54 //Normalize publicId and systemId |
55 systemId = Normalizer.normalizeURI(systemId); |
55 systemId = Normalizer.normalizeURI(Util.getNotNullOrEmpty(systemId)); |
56 publicId = Normalizer.normalizePublicId(Normalizer.decodeURN(publicId)); |
56 publicId = Normalizer.normalizePublicId(Normalizer.decodeURN(Util.getNotNullOrEmpty(publicId))); |
57 |
57 |
58 //check whether systemId is an urn |
58 //check whether systemId is an urn |
59 if (systemId != null && systemId.startsWith("urn:publicid:")) { |
59 if (systemId != null && systemId.startsWith("urn:publicid:")) { |
60 systemId = Normalizer.decodeURN(systemId); |
60 systemId = Normalizer.decodeURN(systemId); |
61 if (publicId != null && !publicId.equals(systemId)) { |
61 if (publicId != null && !publicId.equals(systemId)) { |
85 //no action, allow the parser to continue |
85 //no action, allow the parser to continue |
86 return null; |
86 return null; |
87 } |
87 } |
88 |
88 |
89 /** |
89 /** |
90 * Resolves the publicId or systemId to one specified in the catalog. |
90 * Resolves the publicId or systemId using public or system entries in the catalog. |
|
91 * |
|
92 * The resolution follows the following rules determined by the prefer setting: |
|
93 * |
|
94 * prefer "system": attempts to resolve with a system entry; |
|
95 * attempts to resolve with a public entry when only |
|
96 * publicId is specified. |
|
97 * |
|
98 * prefer "public": attempts to resolve with a system entry; |
|
99 * attempts to resolve with a public entry if no matching |
|
100 * system entry is found. |
91 * @param catalog the catalog |
101 * @param catalog the catalog |
92 * @param publicId the publicId |
102 * @param publicId the publicId |
93 * @param systemId the systemId |
103 * @param systemId the systemId |
94 * @return the resolved systemId if a match is found, null otherwise |
104 * @return the resolved systemId if a match is found, null otherwise |
95 */ |
105 */ |
97 String resolvedSystemId = null; |
107 String resolvedSystemId = null; |
98 |
108 |
99 //search the current catalog |
109 //search the current catalog |
100 catalog.reset(); |
110 catalog.reset(); |
101 if (systemId != null) { |
111 if (systemId != null) { |
|
112 /* |
|
113 If a system identifier is specified, it is used no matter how |
|
114 prefer is set. |
|
115 */ |
102 resolvedSystemId = catalog.matchSystem(systemId); |
116 resolvedSystemId = catalog.matchSystem(systemId); |
103 } |
117 } |
104 if (resolvedSystemId == null) { |
118 |
|
119 if (resolvedSystemId == null && publicId != null) { |
105 resolvedSystemId = catalog.matchPublic(publicId); |
120 resolvedSystemId = catalog.matchPublic(publicId); |
106 } |
121 } |
107 |
122 |
108 //mark the catalog as having been searched before trying alternatives |
123 //mark the catalog as having been searched before trying alternatives |
109 catalog.markAsSearched(); |
124 catalog.markAsSearched(); |