cziegeler 01/09/24 02:19:02
Modified: src/org/apache/cocoon/components/parser XercesParser.java
Log:
This will fix bug 3595 Entity catalogs - XercesParser.java needs
setEntityResolver
- applies the same changes as recently done for JaxpParser.java
to setEntityResolver
PR: bug #3595
Submitted by: David Crossley
Revision Changes Path
1.3 +29 -2
xml-cocoon2/src/org/apache/cocoon/components/parser/XercesParser.java
Index: XercesParser.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/parser/XercesParser.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XercesParser.java 2001/08/20 13:55:12 1.2
+++ XercesParser.java 2001/09/24 09:19:02 1.3
@@ -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;
@@ -25,13 +29,20 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
* (Apache Software Foundation, Exoffice Technologies)
- * @version CVS $Revision: 1.2 $ $Date: 2001/08/20 13:55:12 $
+ * @version CVS $Revision: 1.3 $ $Date: 2001/09/24 09:19:02 $
*/
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);
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]