deweese 2002/08/01 13:24:32
Modified: sources/org/apache/batik/dom/util SAXDocumentFactory.java
sources/org/apache/batik/util ParsedURL.java
ParsedURLData.java
ParsedURLDefaultProtocolHandler.java
Log:
1) Fixed a bug in reading XML documents that do not have an expected namespace
on the root element.
2) Fixed a bug in URL parsing for fragments with no base document.
Revision Changes Path
1.14 +22 -5
xml-batik/sources/org/apache/batik/dom/util/SAXDocumentFactory.java
Index: SAXDocumentFactory.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/dom/util/SAXDocumentFactory.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- SAXDocumentFactory.java 24 Jul 2002 01:19:31 -0000 1.13
+++ SAXDocumentFactory.java 1 Aug 2002 20:24:32 -0000 1.14
@@ -290,9 +290,26 @@
}
- if ((!docElem.getNamespaceURI().equals(nsURI)) ||
- (!docElem.getLocalName().equals(lname))) {
- throw new IOException("Root element does not match requested
Document.");
+ String docElemNS = docElem.getNamespaceURI();
+ if ((docElemNS != nsURI) &&
+ ((docElemNS == null) || (!docElemNS.equals(nsURI))))
+ throw new IOException
+ ("Root element namespace does not match that requested:\n" +
+ "Requested: " + nsURI + "\n" +
+ "Found: " + docElemNS);
+
+ if (docElemNS != null) {
+ if (!docElem.getLocalName().equals(lname))
+ throw new IOException
+ ("Root element does not match that requested:\n" +
+ "Requested: " + lname + "\n" +
+ "Found: " + docElem.getLocalName());
+ } else {
+ if (!docElem.getNodeName().equals(lname))
+ throw new IOException
+ ("Root element does not match that requested:\n" +
+ "Requested: " + lname + "\n" +
+ "Found: " + docElem.getNodeName());
}
return ret;
@@ -457,7 +474,7 @@
while (i.hasNext()) {
PreInfo pi = (PreInfo)i.next();
Node n = pi.createNode(document);
- document.insertBefore(n, e);
+ document.insertBefore(n, e);
}
preInfo = null;
} else {
1.14 +2 -1 xml-batik/sources/org/apache/batik/util/ParsedURL.java
Index: ParsedURL.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/ParsedURL.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ParsedURL.java 11 Jul 2002 16:26:20 -0000 1.13
+++ ParsedURL.java 1 Aug 2002 20:24:32 -0000 1.14
@@ -199,6 +199,7 @@
*/
public ParsedURL(URL baseURL, String urlStr) {
this.userAgent = getGlobalUserAgent();
+
if (baseURL != null)
this.data = parseURL(new ParsedURL(baseURL), urlStr);
else
1.8 +13 -7 xml-batik/sources/org/apache/batik/util/ParsedURLData.java
Index: ParsedURLData.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/ParsedURLData.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ParsedURLData.java 11 Jul 2002 16:26:20 -0000 1.7
+++ ParsedURLData.java 1 Aug 2002 20:24:32 -0000 1.8
@@ -124,18 +124,24 @@
* URL.
*/
protected URL buildURL() throws MalformedURLException {
- String file = "";
- if (path != null)
- file = path;
// System.out.println("File: " + file);
// if (ref != null)
// file += "#" + ref;
+ // System.out.println("Building: " + protocol + " - " +
+ // host + " - " + path);
- if (port == -1)
- return new URL(protocol, host, file);
+ if ((protocol != null) && (host != null)) {
+ String file = "";
+ if (path != null)
+ file = path;
+ if (port == -1)
+ return new URL(protocol, host, file);
- return new URL(protocol, host, port, file);
+ return new URL(protocol, host, port, file);
+ }
+
+ return new URL(toString());
}
/**
1.9 +23 -20
xml-batik/sources/org/apache/batik/util/ParsedURLDefaultProtocolHandler.java
Index: ParsedURLDefaultProtocolHandler.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/util/ParsedURLDefaultProtocolHandler.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ParsedURLDefaultProtocolHandler.java 5 Jun 2002 21:14:48 -0000 1.8
+++ ParsedURLDefaultProtocolHandler.java 1 Aug 2002 20:24:32 -0000 1.9
@@ -75,6 +75,7 @@
}
// new Exception("Custom Parse: " + urlStr).printStackTrace();
+ // System.out.println("Custom Parse: " + urlStr);
ParsedURLData ret = constructParsedURLData();
@@ -82,6 +83,16 @@
int pidx=0, idx;
int len = urlStr.length();
+
+ // Pull fragement id off first...
+ idx = urlStr.indexOf('#');
+ ret.ref = null;
+ if (idx != -1) {
+ if (idx+1 < urlStr.length())
+ ret.ref = urlStr.substring(idx+1);
+ urlStr = urlStr.substring(0,idx);
+ }
+
String prefix = urlStr;
if ((idx = prefix.indexOf('/')) != -1)
// Only check for ':' prior to first '/'
@@ -110,22 +121,19 @@
// No slashes (apache.org) or a double slash
// (//apache.org/....) so
// we should have host[:port] before next slash.
-
- if (idx != -1)
+ if (idx != -1)
pidx+=2; // Skip double slash...
idx = urlStr.indexOf('/', pidx); // find end of host:Port spec
String hostPort;
- if (idx == -1)
+ if (idx == -1)
// Just host and port nothing following...
hostPort = urlStr.substring(pidx);
else
// Path spec follows...
hostPort = urlStr.substring(pidx, idx);
- hostPort = hostPort;
-
- pidx = idx; // Remember location of '/'
+ int hidx = idx; // Remember location of '/'
// pull apart host and port number...
idx = hostPort.indexOf(':');
@@ -150,23 +158,18 @@
}
}
}
+ if (((ret.host == null) || (ret.host.indexOf('.') == -1)) &&
+ (ret.port == -1))
+ // no '.' in a host spec??? and no port, probably
+ // just a path.
+ ret.host = null;
+ else
+ pidx = hidx;
}
if ((pidx == -1) || (pidx >= len)) return ret; // Nothing follows
- String pathRef = urlStr.substring(pidx);
- pathRef = pathRef;
-
- idx = pathRef.indexOf('#');
- ret.ref = null;
- if (idx == -1) {
- // No ref (fragment) in URL
- ret.path = pathRef;
- } else {
- ret.path = pathRef.substring(0,idx);
- if (idx+1 < pathRef.length())
- ret.ref = pathRef.substring(idx+1);
- }
+ ret.path = urlStr.substring(pidx);
return ret;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]