equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
71 |
71 |
72 //Normalize publicId and systemId |
72 //Normalize publicId and systemId |
73 systemId = Normalizer.normalizeURI(Util.getNotNullOrEmpty(systemId)); |
73 systemId = Normalizer.normalizeURI(Util.getNotNullOrEmpty(systemId)); |
74 publicId = Normalizer.normalizePublicId(Normalizer.decodeURN(Util.getNotNullOrEmpty(publicId))); |
74 publicId = Normalizer.normalizePublicId(Normalizer.decodeURN(Util.getNotNullOrEmpty(publicId))); |
75 |
75 |
76 //check whether systemId is an urn |
76 //check whether systemId is a urn |
77 if (systemId != null && systemId.startsWith(Util.URN)) { |
77 if (systemId != null && systemId.startsWith(Util.URN)) { |
78 systemId = Normalizer.decodeURN(systemId); |
78 systemId = Normalizer.decodeURN(systemId); |
79 if (publicId != null && !publicId.equals(systemId)) { |
79 if (publicId != null && !publicId.equals(systemId)) { |
80 systemId = null; |
80 systemId = null; |
81 } else { |
81 } else { |
121 String uri = Normalizer.normalizeURI(href); |
121 String uri = Normalizer.normalizeURI(href); |
122 if (uri == null) { |
122 if (uri == null) { |
123 return null; |
123 return null; |
124 } |
124 } |
125 |
125 |
126 //check whether uri is an urn |
126 //check whether uri is a urn |
127 if (uri != null && uri.startsWith(Util.URN)) { |
127 if (uri != null && uri.startsWith(Util.URN)) { |
128 String publicId = Normalizer.decodeURN(uri); |
128 String publicId = Normalizer.decodeURN(uri); |
129 if (publicId != null) { |
129 if (publicId != null) { |
130 result = Util.resolve(c, publicId, null); |
130 result = Util.resolve(c, publicId, null); |
131 } |
131 } |
132 } |
132 } |
133 |
133 |
134 //if no match with a public id, continue search for an URI |
134 //if no match with a public id, continue search for a URI |
135 if (result == null) { |
135 if (result == null) { |
136 //remove fragment if any. |
136 //remove fragment if any. |
137 int hashPos = uri.indexOf("#"); |
137 int hashPos = uri.indexOf("#"); |
138 if (hashPos >= 0) { |
138 if (hashPos >= 0) { |
139 uri = uri.substring(0, hashPos); |
139 uri = uri.substring(0, hashPos); |