You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2003/08/20 20:47:24 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl XMLEntityManager.java
mrglavas 2003/08/20 11:47:24
Modified: java/src/org/apache/xerces/impl XMLEntityManager.java
Log:
Errata fo XML 1.0 Second Edition:
E43 (partial): the base URI is the URI of the resource after all redirection has occurred.
Fixes Bug #20383.
Revision Changes Path
1.65 +20 -3 xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java
Index: XMLEntityManager.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- XMLEntityManager.java 27 Mar 2003 16:27:34 -0000 1.64
+++ XMLEntityManager.java 20 Aug 2003 18:47:24 -0000 1.65
@@ -63,6 +63,8 @@
import java.io.Reader;
import java.io.StringReader;
import java.net.URL;
+import java.net.HttpURLConnection;
+import java.net.URLConnection;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Stack;
@@ -917,7 +919,7 @@
// get information
final String publicId = xmlInputSource.getPublicId();
- final String literalSystemId = xmlInputSource.getSystemId();
+ String literalSystemId = xmlInputSource.getSystemId();
String baseSystemId = xmlInputSource.getBaseSystemId();
String encoding = xmlInputSource.getEncoding();
Boolean isBigEndian = null;
@@ -933,7 +935,22 @@
if (reader == null) {
stream = xmlInputSource.getByteStream();
if (stream == null) {
- stream = new URL(expandedSystemId).openStream();
+ URL location = new URL(expandedSystemId);
+ URLConnection connect = location.openConnection();
+ stream = connect.getInputStream();
+
+ // REVISIT: If the URLConnection has external encoding
+ // information, we should be reading it here. It's located
+ // in the charset parameter of Content-Type. -- mrglavas
+ if (connect instanceof HttpURLConnection) {
+ String redirect = connect.getURL().toString();
+ // E43: Check if the URL was redirected, and then
+ // update literal and expanded system IDs if needed.
+ if (!redirect.equals(expandedSystemId)) {
+ literalSystemId = redirect;
+ expandedSystemId = redirect;
+ }
+ }
}
// wrap this stream in RewindableInputStream
stream = new RewindableInputStream(stream);
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org