I've been looking over how to configure the xml-rpc sax parser, which is
now hard-configured to 'xerces'.

There are a few different places where it comes up:

org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl

    - DatabaseImpl is Configurable; set a property on DatabaseImpl,
      export it to CollectionImpl.

org.apache.xindice.server.XindiceServlet

    - Use the web.xml file to set a property that can be accessed via
        the ServletContext during init().

org.apache.xindice.admin.XindiceAdmin
org.apache.xindice.client.xmldb.xmlrpcssl.CollectionImpl

    - in the scratchpad directory... does anybody care?


Untried patches attached for CollectionImpl and XindiceServlet.  Let me
know if this is a satisfactory approach and I'll write tests and so
on...

        Gary

On Fri, 14 Feb 2003, at 08:34 [-0500], Matt Liotta ([EMAIL PROTECTED]) wrote:

> Actually I wasn't volunteering, but if no one else is working on it then
> my company will likely tackle the problem in the coming months. I just
> didn't want to waste resources on work someone else was doing.
>
> BTW, any Xindice hackers out there who are looking for contract work
> implementing changes to Xindice?
>
> Matt Liotta
> President & CEO
> Montara Software, Inc.
> http://www.montarasoftware.com/
> 888-408-0900 x901
>
> > -----Original Message-----
> > From: Vladimir R. Bossicard [mailto:[EMAIL PROTECTED]
> > Sent: Friday, February 14, 2003 8:24 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Xerces dependency
> >
> > > Any plans to remove the Xerces dependency from Xindice and support
> JAXP
> > > instead?
> >
> > Thank you for volunteering :-)
> >
> > I'm not aware of any plan but if JAXP is smaller, faster you have my
> +1.
> >
> > -Vladimir
> >
> > --
> > Vladimir R. Bossicard
> > Apache Xindice - http://xml.apache.org/xindice
>
>
>
Index: java/src/org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java
===================================================================
RCS file: 
/home/cvspublic/xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java,v
retrieving revision 1.20
diff -u -r1.20 CollectionImpl.java
--- java/src/org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java 30 Dec 
2002 11:06:06 -0000      1.20
+++ java/src/org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java 18 Feb 
2003 05:04:22 -0000
@@ -62,6 +62,7 @@
 import java.io.StringReader;
 import java.net.MalformedURLException;
 import java.util.Hashtable;
+import java.util.Properties;
 import java.util.Vector;
 
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -108,28 +109,41 @@
    /* the XML-RPC client stub, connected to server */
    private XmlRpcClient client = null;
 
-
+   /*
+    * Properties inherited from DatabaseImpl. Currently only the xml-rpc sax
+    * parser (xmlrpc-sax-parser-classname) is supported.  It would be more
+    * elegant to add them to the local <code>CommonCollection</code>, but less
+    * efficient.
+    */
+   private Properties inheritedProperties;
+   
     /**
      * Creates new <code>CollectionImpl</code> instance representing connection
      * to server collection.
      *
      * @param hostPort hostname and port number in <code>host:port</code> 
format.
      *        Port no is optional, in which case HTTP default is assumed.
+     * @param collPath
+     * @param inheritedProperties from DatabaseImpl; currently only
+     *        'xmlrpc-sax-parser-classname' is supported.
      * @exception XMLDBException thrown if a connection could not be 
established,
      *            because of URL syntax errors, or connection failure, or if no
      *            collection with path <code>collPath</code> could be located.
      */
-    public CollectionImpl(String hostPort, String collPath) throws 
XMLDBException {
+    public CollectionImpl(String hostPort, String collPath, Properties 
inheritedProperties)
+            throws XMLDBException {
         super(collPath);
        
         this.hostPort = hostPort;
         this.collPath = collPath;
+        this.inheritedProperties = inheritedProperties;
+        
         String xmlrpcURI = "http://"; + hostPort + XINDICE_SERVICE_LOCATION;
         XmlRpc.setEncoding("UTF8");
         XmlRpc.setKeepAlive(true);
         try {
-            
-            XmlRpc.setDriver("xerces");
+            XmlRpc.setDriver(
+                inheritedProperties.getProperty("xmlrpc-sax-parser-classname", 
"xerces"));
         } catch (Exception e) {
             
             throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Xerces needed", 
e);
@@ -326,7 +340,7 @@
       }
 
       try {
-         return new CollectionImpl(hostPort, collPath + "/" + name);
+         return new CollectionImpl(hostPort, collPath + "/" + name, 
inheritedProperties);
       }
       catch (XMLDBException e) {
          if (e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
@@ -396,8 +410,9 @@
       }
 
       try {
-         return new CollectionImpl(hostPort, collPath.substring(0,
-               collPath.lastIndexOf('/')));
+         return new CollectionImpl(hostPort,
+            collPath.substring(0, collPath.lastIndexOf('/')),
+            inheritedProperties);
       }
       catch (XMLDBException e) {
          if (e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
Index: java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java
===================================================================
RCS file: 
/home/cvspublic/xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java,v
retrieving revision 1.7
diff -u -r1.7 DatabaseImpl.java
--- java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java   21 Nov 
2002 07:44:35 -0000      1.7
+++ java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java   18 Feb 
2003 05:04:22 -0000
@@ -57,6 +57,9 @@
  *
  * $Id: DatabaseImpl.java,v 1.7 2002/11/21 07:44:35 vladimir Exp $
  */
+
+import java.util.Properties;
+
 import org.apache.xindice.client.xmldb.CommonConfigurable;
 
 import org.xmldb.api.base.Collection;
@@ -151,16 +154,31 @@
             hostPort = "127.0.0.1:8080";
         }
         
-               try {
-        return new CollectionImpl(hostPort, collPath);
-               }
-               catch(XMLDBException e) {
+        /*
+         * Assemble properties used by the Collection.
+         * Currently only the xml-rpc sax parser.
+         */
+        Properties props = new Properties();
+        try {
+            props.setProperty("xmlrpc-sax-parser-classname",
+                getProperty("xmlrpc-sax-parser-classname"));
+        } catch(XMLDBException e) {
+            /*
+             * As far as I can see this exception should never happen,
+             * and the significance is unclear (i.e., undocumented in
+             * the XMLDB spcec) if it does.
+             */
+        }
+        
+       try {
+            return new CollectionImpl(hostPort, collPath, props);
+       } catch(XMLDBException e) {
            if(e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
               // per getCollection contract, return null if not found
               return null;
            }
-                  throw e;
-               }
+          throw e;
+       }
     }
     
     /**
Index: java/src/org/apache/xindice/server/XindiceServlet.java
===================================================================
RCS file: 
/home/cvspublic/xml-xindice/java/src/org/apache/xindice/server/XindiceServlet.java,v
retrieving revision 1.10
diff -u -r1.10 XindiceServlet.java
--- java/src/org/apache/xindice/server/XindiceServlet.java      13 Dec 2002 
09:02:19 -0000      1.10
+++ java/src/org/apache/xindice/server/XindiceServlet.java      18 Feb 2003 
05:04:22 -0000
@@ -187,11 +187,21 @@
 
       // Setup the XML-RPC impl to support UTF-8 input via Xerces.
       XmlRpc.setEncoding("UTF8");
+      
+      /*
+       * Get the sax parser classname (or shorthand) from the servlet context.
+       * Support the original default of xerces, if the servlet parameter is 
missing.
+       */
+      String configuredDriverName = 
config.getServletContext().getInitParameter("xmlrpc-sax-parser-classname");
+      String driverName = configuredDriverName != null ? configuredDriverName 
: "xerces";
       try {
-         // TODO: This introduces a firm dependency on xerces. fix it.
-         XmlRpc.setDriver("xerces");
+         XmlRpc.setDriver(driverName);
       } catch (Exception e) {
-         throw new ServletException("XML-RPC support requires Xerces", e);
+         throw new ServletException(
+            "XML-RPC error message: '"
+                + e.getMessage()
+                + "'",
+            e);
       }
 
       // Create the XML-RPC server and add our handler as the default.

Reply via email to