Update of /var/cvs/src/org/mmbase/bridge/util/xml
In directory james.mmbase.org:/tmp/cvs-serv30136

Modified Files:
      Tag: MMBase-1_8
        Generator.java 
Log Message:
The ridiculous fact that setIdAttribute is only available in dom level 3, hence 
only in java 1.5, is causing me headaches.


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/bridge/util/xml


Index: Generator.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/bridge/util/xml/Generator.java,v
retrieving revision 1.39.2.3
retrieving revision 1.39.2.4
diff -u -b -r1.39.2.3 -r1.39.2.4
--- Generator.java      14 Feb 2008 15:35:24 -0000      1.39.2.3
+++ Generator.java      15 Feb 2008 12:47:37 -0000      1.39.2.4
@@ -26,7 +26,7 @@
  *
  * @author Michiel Meeuwissen
  * @author Eduard Witteveen
- * @version $Id: Generator.java,v 1.39.2.3 2008/02/14 15:35:24 michiel Exp $
+ * @version $Id: Generator.java,v 1.39.2.4 2008/02/15 12:47:37 michiel Exp $
  * @since  MMBase-1.6
  */
 public class Generator {
@@ -297,13 +297,24 @@
     }
 
     /**
-     * Just to override if you happen to use java 1.5.
+     * setIdAttribute only DOM level 3. But this can very much increase 
performance.
+     *
+     * Some XSLS e.g. those of mmbase-richtext depend on this.
+     * Now for these case we have a runtime dependency.
      * @since MMBase-1.8.6
      * This method will not be added to mmbase 1.9. We use java 1.5 there, and 
simply call
-     * object.setIdAttribute directoy.
+     * object.setIdAttribute directly.
      */
     protected void setIdAttribute(Element object, String name) {
-        //object.setIdAttribute(name, true);
+        Class cl = object.getClass();
+        try {
+            java.lang.reflect.Method m =  cl.getMethod("setIdAttribute", new 
Class[] {String.class, Boolean.TYPE});
+            m.invoke(object, new Object[] {name, Boolean.TRUE});
+        } catch(NoSuchMethodException nsme) {
+            log.warn(nsme + "Try a better dom implementation. This one 
sucks.", nsme);
+        } catch(Exception iae) {
+            throw new RuntimeException(iae);
+        }
     }
     /**
      * Creates an Element which represents a bridge.Node with all fields 
unfilled.
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to