I posted this patch directly to Bugzilla last week. However, it has
not yet been applied. So i will post it here too. 

This will fix bug 3595 Entity catalogs - XercesParser.java needs 
setEntityResolver

- applies the same changes as recently done for JaxpParser.java
to setEntityResolver

David Crossley
Index: XercesParser.java
===================================================================
RCS file: 
/home/cvspublic/xml-cocoon2/src/org/apache/cocoon/components/parser/XercesParser.java,v
retrieving revision 1.2
diff -u -r1.2 XercesParser.java
--- XercesParser.java   2001/08/20 13:55:12     1.2
+++ XercesParser.java   2001/09/20 06:39:37
@@ -7,7 +7,11 @@
  *****************************************************************************/
 package org.apache.cocoon.components.parser;
 
+import org.apache.avalon.framework.component.ComponentException;
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.component.Composable;
 import org.apache.avalon.framework.thread.SingleThreaded;
+import org.apache.cocoon.components.resolver.Resolver;
 import org.apache.cocoon.xml.AbstractXMLProducer;
 import org.apache.xerces.dom.DocumentImpl;
 import org.apache.xerces.dom.DocumentTypeImpl;
@@ -28,10 +32,17 @@
  * @version CVS $Revision: 1.2 $ $Date: 2001/08/20 13:55:12 $
  */
 public class XercesParser extends AbstractXMLProducer
-implements Parser, ErrorHandler, SingleThreaded {
+implements Parser, ErrorHandler, Composable, SingleThreaded {
 
+    /** the SAX Parser */
     final SAXParser parser;
 
+    /** the component manager */
+    protected ComponentManager manager;
+
+    /** the Entity Resolver */
+    protected Resolver resolver = null;
+
     public XercesParser ()
     throws SAXException {
         this.parser = new SAXParser();
@@ -42,12 +53,28 @@
                           true);
     }
 
+    /**
+     * Get the Entity Resolver from the component manager
+     */
+    public void compose(ComponentManager manager) throws ComponentException {
+      try {
+        this.manager = manager;
+        getLogger().debug("Looking up " + Resolver.ROLE);
+        this.resolver = (Resolver)manager.lookup(Resolver.ROLE);
+      } catch(ComponentException e) {
+               // This exception is ok during initialization/startup.
+        getLogger().debug("Error in XercesParser: Cannot find " + Resolver.ROLE);
+      }
+    }
+
     public void parse(InputSource in)
     throws SAXException, IOException {
       this.parser.setProperty("http://xml.org/sax/properties/lexical-handler";,
                               super.lexicalHandler);
         this.parser.setErrorHandler(this);
         this.parser.setContentHandler(super.contentHandler);
+        if(this.resolver != null)
+          this.parser.setEntityResolver(this.resolver);
         this.parser.parse(in);
     }
 
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to