[kaffe] CVS kaffe (robilad): Resynced with GNU JAXP: Added initial XPath support and small fixes

Kaffe CVS cvs-commits at kaffe.org
Sun Oct 10 11:47:03 PDT 2004


PatchSet 5264 
Date: 2004/10/10 18:43:11
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU JAXP: Added initial XPath support and small fixes

2004-10-10  Dalibor Topic  <robilad at kaffe.org>

        * libraries/javalib/gnu/xml/dom/DomXPathExpression.java,
        libraries/javalib/gnu/xml/dom/DomXPathNSResolver.java:
        New files, taken from GNU JAXP.

        * libraries/clib/libxmlj/xmlj_error.c,
        libraries/clib/libxmlj/xmlj_util.c,
        libraries/javalib/gnu/xml/dom/DomDocument.java:
        Resynced with GNU JAXP.

        * libraries/javalib/Makefile.am,
        libraries/javalib/Makefile.in,
        libraries/javalib/all.files:
        Regenarated.

        2004-10-06  Chris Burdess  <dog at gnu.org>

        * dom: Added framework for XPath expression evaluation.

        2004-10-08  Chris Burdess <dog at gnu.org>

        * xmlj_util.c: String caching only by setting macro.

        2004-10-06  Chris Burdess <dog at gnu.org>

        * xmlj_util.c,xmlj_error.c: Call fflush after fprintf.

Members: 
	ChangeLog:1.2817->1.2818 
	libraries/clib/libxmlj/xmlj_error.c:1.4->1.5 
	libraries/clib/libxmlj/xmlj_util.c:1.4->1.5 
	libraries/javalib/Makefile.am:1.249->1.250 
	libraries/javalib/Makefile.in:1.329->1.330 
	libraries/javalib/all.files:1.37->1.38 
	libraries/javalib/gnu/xml/dom/DomDocument.java:1.5->1.6 
	libraries/javalib/gnu/xml/dom/DomXPathExpression.java:INITIAL->1.1 
	libraries/javalib/gnu/xml/dom/DomXPathNSResolver.java:INITIAL->1.1 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2817 kaffe/ChangeLog:1.2818
--- kaffe/ChangeLog:1.2817	Sun Oct 10 17:57:28 2004
+++ kaffe/ChangeLog	Sun Oct 10 18:43:11 2004
@@ -1,5 +1,33 @@
 2004-10-10  Dalibor Topic  <robilad at kaffe.org>
 
+	* libraries/javalib/gnu/xml/dom/DomXPathExpression.java,
+	libraries/javalib/gnu/xml/dom/DomXPathNSResolver.java:
+	New files, taken from GNU JAXP.
+
+	* libraries/clib/libxmlj/xmlj_error.c,
+	libraries/clib/libxmlj/xmlj_util.c,
+	libraries/javalib/gnu/xml/dom/DomDocument.java:
+	Resynced with GNU JAXP.
+
+	* libraries/javalib/Makefile.am,
+	libraries/javalib/Makefile.in,
+	libraries/javalib/all.files:
+	Regenarated.
+
+	2004-10-06  Chris Burdess  <dog at gnu.org>
+
+        * dom: Added framework for XPath expression evaluation.
+
+	2004-10-08  Chris Burdess <dog at gnu.org>
+
+        * xmlj_util.c: String caching only by setting macro.
+
+	2004-10-06  Chris Burdess <dog at gnu.org>
+
+        * xmlj_util.c,xmlj_error.c: Call fflush after fprintf.
+
+2004-10-10  Dalibor Topic  <robilad at kaffe.org>
+
 	* libraries/javalib/Makefile.am,
 	libraries/javalib/Makefile.in,
 	libraries/javalib/all.files:
Index: kaffe/libraries/clib/libxmlj/xmlj_error.c
diff -u kaffe/libraries/clib/libxmlj/xmlj_error.c:1.4 kaffe/libraries/clib/libxmlj/xmlj_error.c:1.5
--- kaffe/libraries/clib/libxmlj/xmlj_error.c:1.4	Mon Jul 26 02:40:57 2004
+++ kaffe/libraries/clib/libxmlj/xmlj_error.c	Sun Oct 10 18:43:13 2004
@@ -91,8 +91,9 @@
     {
       va_list va;
       va_start (va, msg);
-      printf ("libxslt error: ");
-      vprintf (msg, va);
+      fprintf (stderr, "libxslt error: ");
+      vfprintf (stderr, msg, va);
+      fflush (stderr);
       va_end (va);
     }
 }
@@ -112,12 +113,14 @@
   if (cls == NULL)
     {
       fprintf (stderr, "Can't find class %s\n", classname);
+      fflush (stderr);
       return;
     }
   method = (*env)->GetMethodID (env, cls, "<init>", "(Ljava/lang/String;)V");
   if (method == NULL)
     {
-      printf ("Can't find method %s.<init>\n", classname);
+      fprintf (stderr, "Can't find method %s.<init>\n", classname);
+      fflush (stderr);
       return;
     }
   jmsg = (message == NULL) ? NULL : (*env)->NewStringUTF (env, message);
@@ -125,6 +128,7 @@
   if (ex == NULL)
     {
       fprintf (stderr, "Can't instantiate new %s\n", classname);
+      fflush (stderr);
       return;
     }
   (*env)->Throw (env, ex);
@@ -149,12 +153,14 @@
   if (cls == NULL)
     {
       fprintf (stderr, "Can't find DOMException class!\n");
+      fflush (stderr);
       return;
     }
   method = (*env)->GetMethodID (env, cls, "<init>", "(SLjava/lang/String;)V");
   if (method == NULL)
     {
       fprintf (stderr, "Can't find DOMException constructor!\n");
+      fflush (stderr);
       return;
     }
   jmsg = (message == NULL) ? NULL : (*env)->NewStringUTF (env, message);
Index: kaffe/libraries/clib/libxmlj/xmlj_util.c
diff -u kaffe/libraries/clib/libxmlj/xmlj_util.c:1.4 kaffe/libraries/clib/libxmlj/xmlj_util.c:1.5
--- kaffe/libraries/clib/libxmlj/xmlj_util.c:1.4	Mon Aug 16 02:43:43 2004
+++ kaffe/libraries/clib/libxmlj/xmlj_util.c	Sun Oct 10 18:43:13 2004
@@ -30,6 +30,7 @@
 #include <unistd.h>
 
 /* xmlChar->jstring cache */
+#ifdef XMLJ_STRING_CACHE
 #define XMLJ_STRING_CACHE_SIZE 1024
 xmlHashTablePtr xmljStringCache = NULL;
 
@@ -41,6 +42,7 @@
 {
   /* NOOP */
 }
+#endif /* XMLJ_STRING_CACHE */
 
 jstring
 xmljNewString (JNIEnv * env, const xmlChar * text)
@@ -51,6 +53,7 @@
     {
       return NULL;
     }
+#ifdef XMLJ_STRING_CACHE
   if (xmljStringCache == NULL) /* Init cache */
     {
       xmljStringCache = xmlHashCreate (XMLJ_STRING_CACHE_SIZE);
@@ -61,23 +64,33 @@
       ret = (*env)->NewStringUTF (env, (char *) text);
       if (ret == NULL) /* Why? */
         {
-          printf("xmljNewString: ERROR: NewStringUTF returned null for \"%s\"\n", text);
+          fprintf(stderr, "xmljNewString: ERROR: NewStringUTF returned null for \"%s\"\n", text);
+          fflush (stderr);
         }
       else
         {
           xmlHashAddEntry (xmljStringCache, text, ret);
         }
     }
+#else
+  ret = (*env)->NewStringUTF (env, (char *) text);
+  if (ret == NULL) /* Why? */
+    {
+      printf("xmljNewString: ERROR: NewStringUTF returned null for \"%s\"\n", text);
+    }
+#endif /* XMLJ_STRING_CACHE */
   return ret;
 }
 
 void
 xmljClearStringCache ()
 {
+#ifdef XMLJ_STRING_CACHE
   if (xmljStringCache != NULL)
     {
       xmlHashFree (xmljStringCache, &xmljHashDeallocate);
     }
+#endif /* XMLJ_STRING_CACHE */
 }
 
 const xmlChar *
Index: kaffe/libraries/javalib/Makefile.am
diff -u kaffe/libraries/javalib/Makefile.am:1.249 kaffe/libraries/javalib/Makefile.am:1.250
--- kaffe/libraries/javalib/Makefile.am:1.249	Sun Oct 10 17:57:34 2004
+++ kaffe/libraries/javalib/Makefile.am	Sun Oct 10 18:43:15 2004
@@ -1358,6 +1358,8 @@
 	gnu/xml/dom/DomNsNode.java \
 	gnu/xml/dom/DomPI.java \
 	gnu/xml/dom/DomText.java \
+	gnu/xml/dom/DomXPathExpression.java \
+	gnu/xml/dom/DomXPathNSResolver.java \
 	gnu/xml/dom/ImplementationList.java \
 	gnu/xml/dom/ImplementationSource.java \
 	gnu/xml/dom/JAXPFactory.java
Index: kaffe/libraries/javalib/Makefile.in
diff -u kaffe/libraries/javalib/Makefile.in:1.329 kaffe/libraries/javalib/Makefile.in:1.330
--- kaffe/libraries/javalib/Makefile.in:1.329	Sun Oct 10 17:57:35 2004
+++ kaffe/libraries/javalib/Makefile.in	Sun Oct 10 18:43:15 2004
@@ -1798,6 +1798,8 @@
 	gnu/xml/dom/DomNsNode.java \
 	gnu/xml/dom/DomPI.java \
 	gnu/xml/dom/DomText.java \
+	gnu/xml/dom/DomXPathExpression.java \
+	gnu/xml/dom/DomXPathNSResolver.java \
 	gnu/xml/dom/ImplementationList.java \
 	gnu/xml/dom/ImplementationSource.java \
 	gnu/xml/dom/JAXPFactory.java
Index: kaffe/libraries/javalib/all.files
diff -u kaffe/libraries/javalib/all.files:1.37 kaffe/libraries/javalib/all.files:1.38
--- kaffe/libraries/javalib/all.files:1.37	Sun Oct 10 17:57:37 2004
+++ kaffe/libraries/javalib/all.files	Sun Oct 10 18:43:16 2004
@@ -940,6 +940,8 @@
 gnu/xml/dom/DomNsNode.java
 gnu/xml/dom/DomPI.java
 gnu/xml/dom/DomText.java
+gnu/xml/dom/DomXPathExpression.java
+gnu/xml/dom/DomXPathNSResolver.java
 gnu/xml/dom/ImplementationList.java
 gnu/xml/dom/ImplementationSource.java
 gnu/xml/dom/JAXPFactory.java
Index: kaffe/libraries/javalib/gnu/xml/dom/DomDocument.java
diff -u kaffe/libraries/javalib/gnu/xml/dom/DomDocument.java:1.5 kaffe/libraries/javalib/gnu/xml/dom/DomDocument.java:1.6
--- kaffe/libraries/javalib/gnu/xml/dom/DomDocument.java:1.5	Fri Sep 17 21:02:01 2004
+++ kaffe/libraries/javalib/gnu/xml/dom/DomDocument.java	Sun Oct 10 18:43:17 2004
@@ -42,6 +42,10 @@
 
 import org.w3c.dom.*;
 import org.w3c.dom.traversal.*;
+import org.w3c.dom.xpath.XPathEvaluator;
+import org.w3c.dom.xpath.XPathException;
+import org.w3c.dom.xpath.XPathExpression;
+import org.w3c.dom.xpath.XPathNSResolver;
 
 
 /**
@@ -56,7 +60,7 @@
  * @author David Brownell 
  */
 public class DomDocument extends DomNode
-    implements Document, DocumentTraversal
+    implements Document, DocumentTraversal, XPathEvaluator
 {
     private final DOMImplementation	implementation;
     private boolean			checkingCharacters = true;
@@ -802,82 +806,108 @@
     // DOM Level 3 methods
 
     public String getInputEncoding ()
-      {
-        // TODO
-        return null;
-      }
+    {
+      // TODO
+      return null;
+    }
 
     public String getXmlEncoding ()
-      {
-        // TODO
-        return null;
-      }
+    {
+      // TODO
+      return null;
+    }
 
     public boolean getXmlStandalone ()
-      {
-        // TODO
-        return false;
-      }
+    {
+      // TODO
+      return false;
+    }
 
     public void setXmlStandalone (boolean xmlStandalone)
-      {
-        // TODO
-      }
+    {
+      // TODO
+    }
 
     public String getXmlVersion ()
-      {
-        // TODO
-        return null;
-      }
+    {
+      // TODO
+      return null;
+    }
 
     public void setXmlVersion (String xmlVersion)
-      {
-        // TODO
-      }
+    {
+      // TODO
+    }
 
     public boolean getStrictErrorChecking ()
-      {
-        // TODO
-        return false;
-      }
+    {
+      // TODO
+      return false;
+    }
 
     public void setStrictErrorChecking (boolean strictErrorChecking)
-      {
-        // TODO
-      }
+    {
+      // TODO
+    }
 
     public String getDocumentURI ()
-      {
-        // TODO
-        return null;
-      }
+    {
+      // TODO
+      return null;
+    }
 
     public void setDocumentURI (String documentURI)
-      {
-        // TODO
-      }
+    {
+      // TODO
+    }
 
     public Node adoptNode (Node source)
-      {
-        // TODO
-        return null;
-      }
+    {
+      // TODO
+      return null;
+    }
 
     public DOMConfiguration getDomConfig ()
-      {
-        // TODO
-        return null;
-      }
+    {
+      // TODO
+      return null;
+    }
 
     public void normalizeDocument ()
-      {
-        // TODO
-      }
+    {
+      // TODO
+    }
 
     public Node renameNode (Node n, String namespaceURI, String qualifiedName)
-      {
-        // TODO
-        return null;
-      }
+    {
+      // TODO
+      return null;
+    }
+
+    // -- XPathEvaluator --
+
+    public XPathExpression createExpression (String expression,
+                                             XPathNSResolver resolver)
+      throws XPathException, DOMException
+    {
+      return new DomXPathExpression (this, expression, resolver);
+    }
+    
+    public XPathNSResolver createNSResolver (Node nodeResolver)
+    {
+      return new DomXPathNSResolver (nodeResolver);
+    }
+    
+    public Object evaluate (String expression,
+                            Node contextNode,
+                            XPathNSResolver resolver,
+                            short type,
+                            Object result)
+      throws XPathException, DOMException
+    {
+      XPathExpression xpe =
+        new DomXPathExpression (this, expression, resolver);
+      return xpe.evaluate (contextNode, type, result);
+    }
 
 }
===================================================================
Checking out kaffe/libraries/javalib/gnu/xml/dom/DomXPathExpression.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/xml/dom/DomXPathExpression.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/xml/dom/DomXPathExpression.java	Sun Oct 10 18:47:03 2004
@@ -0,0 +1,75 @@
+/*
+ * DomXPathExpression.java
+ * Copyright (C) 2004 The Free Software Foundation
+ * 
+ * This file is part of GNU JAXP, a library.
+ *
+ * GNU JAXP is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * GNU JAXP is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Linking this library statically or dynamically with other modules is
+ * making a combined work based on this library.  Thus, the terms and
+ * conditions of the GNU General Public License cover the whole
+ * combination.
+ *
+ * As a special exception, the copyright holders of this library give you
+ * permission to link this library with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module.  An independent module is a module which is not derived from
+ * or based on this library.  If you modify this library, you may extend
+ * this exception to your version of the library, but you are not
+ * obliged to do so.  If you do not wish to do so, delete this
+ * exception statement from your version. 
+ */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
+import org.w3c.dom.xpath.XPathException;
+import org.w3c.dom.xpath.XPathExpression;
+import org.w3c.dom.xpath.XPathNSResolver;
+
+/**
+ * An XPath expression.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+class DomXPathExpression
+implements XPathExpression
+{
+
+  DomDocument doc;
+  String expression;
+  XPathNSResolver resolver;
+
+  DomXPathExpression (DomDocument doc, String expression,
+                      XPathNSResolver resolver)
+  {
+    this.doc = doc;
+    this.expression = expression;
+    this.resolver = resolver;
+  }
+
+  public Object evaluate (Node contextNode, short type, Object result)
+    throws XPathException, DOMException
+  {
+    // TODO
+    return null;
+  }
+  
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/xml/dom/DomXPathNSResolver.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/xml/dom/DomXPathNSResolver.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/xml/dom/DomXPathNSResolver.java	Sun Oct 10 18:47:03 2004
@@ -0,0 +1,65 @@
+/*
+ * DomXPathNSResolver.java
+ * Copyright (C) 2004 The Free Software Foundation
+ * 
+ * This file is part of GNU JAXP, a library.
+ *
+ * GNU JAXP is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * GNU JAXP is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Linking this library statically or dynamically with other modules is
+ * making a combined work based on this library.  Thus, the terms and
+ * conditions of the GNU General Public License cover the whole
+ * combination.
+ *
+ * As a special exception, the copyright holders of this library give you
+ * permission to link this library with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module.  An independent module is a module which is not derived from
+ * or based on this library.  If you modify this library, you may extend
+ * this exception to your version of the library, but you are not
+ * obliged to do so.  If you do not wish to do so, delete this
+ * exception statement from your version. 
+ */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.xpath.XPathNSResolver;
+
+/**
+ * Generic XPath namespace resolver using a DOM Node.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+class DomXPathNSResolver
+implements XPathNSResolver
+{
+
+  Node node;
+
+  DomXPathNSResolver (Node node)
+  {
+    this.node = node;
+  }
+
+  public String lookupNamespaceURI (String prefix)
+  {
+    return node.lookupNamespaceURI (prefix);
+  }
+  
+}




More information about the kaffe mailing list