stefano 00/07/21 16:39:56
Modified: src/org/apache/cocoon/parser XercesParser.java
Log:
Xerces requires fully resolved URIs as SystemID
Revision Changes Path
1.10 +18 -3 xml-cocoon/src/org/apache/cocoon/parser/XercesParser.java
Index: XercesParser.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/parser/XercesParser.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XercesParser.java 2000/05/18 21:51:37 1.9
+++ XercesParser.java 2000/07/21 23:39:55 1.10
@@ -1,4 +1,4 @@
-/*-- $Id: XercesParser.java,v 1.9 2000/05/18 21:51:37 stefano Exp $ --
+/*-- $Id: XercesParser.java,v 1.10 2000/07/21 23:39:55 stefano Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -63,7 +63,7 @@
* This class implements an XML parser using the Apache Xerces XML parser.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version $Revision: 1.9 $ $Date: 2000/05/18 21:51:37 $
+ * @version $Revision: 1.10 $ $Date: 2000/07/21 23:39:55 $
*/
public class XercesParser extends AbstractParser implements Status {
@@ -81,10 +81,25 @@
parser.setFeature("http://apache.org/xml/features/dom/create-entity-ref-nodes",
false);
parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion",
true);
parser.setFeature("http://apache.org/xml/features/allow-java-encodings", true);
- parser.parse(input);
+ parser.parse(resolveSystemId(input));
return parser.getDocument();
}
+ /*
+ * Make sure the SystemID is fully resolved as the SAX2 spec recommends.
+ */
+ private InputSource resolveSystemId(InputSource input) {
+ String id = input.getSystemId();
+ if (id != null) {
+ id = id.replace('\\','/');
+ if ((id.indexOf("://") < 0) && (!id.startsWith("file:"))) {
+ id = "file:" + id;
+ }
+ input.setSystemId(id);
+ }
+ return input;
+ }
+
/**
* Creates an empty DOM tree.
*/