Hi,
I notice that the HTML parser in gnu.xml.dom.html2 depends on
gnu.javax.swing and javax.swing packages. That is because it basically
extends the Swing HTML parser. The problem that I have is that we (==
Aicas) also would like to build with GUI-less configurations, that means
without AWT and Swing. The situation now is that ripping out AWT and
Swing also means ripping out the whole DOM stuff because of this
dependency.
Ideally I would like to have an independent DOM HTML parser, and let the
Swing HTML parser extend that, instead of doing it the other way round.
I already contacted Audrius in private for suggestions on solving this
dependency problem. My solution for now is to decouple the dependency by
detecting and loading the DomHTMLImpl dynamically. Is this ok to check
in?
2005-08-25 Roman Kennke <address@hidden>
* gnu/xml/dom/DomImpl.java
(hasFeature): Dynamically detect if there actually is a HTML
parser implementation present.
(getFeature): Dynamically load the DomHTMLImpl. This decouples
the XML/HTML packages from the Swing packages.
/Roman
------------------------------------------------------------------------
Index: gnu/xml/dom/DomImpl.java
===================================================================
RCS file: /CVSROOT/Jamaica/src/classpath/gnu/xml/dom/DomImpl.java,v
retrieving revision 1.1
diff -u -r1.1 DomImpl.java
--- gnu/xml/dom/DomImpl.java 24 Aug 2005 11:01:51 -0000 1.1
+++ gnu/xml/dom/DomImpl.java 25 Aug 2005 10:25:45 -0000
@@ -47,7 +47,7 @@
import org.w3c.dom.ls.LSOutput;
import org.w3c.dom.ls.LSParser;
import org.w3c.dom.ls.LSSerializer;
-import gnu.xml.dom.html2.DomHTMLImpl;
+//import gnu.xml.dom.html2.DomHTMLImpl;
import gnu.xml.dom.ls.DomLSInput;
import gnu.xml.dom.ls.DomLSOutput;
import gnu.xml.dom.ls.DomLSParser;
@@ -153,9 +153,19 @@
}
else if ("html".equals(name) || "xhtml".equals(name))
{
- return (version == null ||
- "".equals(version) ||
- "2.0".equals(version));
+ boolean hasHtmlParser = true;
+ try
+ {
+ Class.forName("gnu.xml.dom.html2.DomHTMLImpl");
+ }
+ catch (ClassNotFoundException ex)
+ {
+ hasHtmlParser = false;
+ }
+ return (hasHtmlParser
+ && (version == null ||
+ "".equals(version) ||
+ "2.0".equals(version)));
}
// views
@@ -244,7 +254,29 @@
if ("html".equalsIgnoreCase(feature) ||
"xhtml".equalsIgnoreCase(feature))
{
- return new DomHTMLImpl();
+ // FIXME: This decouples dependency on HTML parser. This is
+ // necessary because the HTML parser depends on the Swing HTML
+ // parser stuff and this would disable XML/HTML parser for
+ // GUI-less configurations.
+ Object res = null;
+ try
+ {
+ Class domHtmlImplClass =
Class.forName("gnu.xml.dom.html2.DomHTMLImpl");
+ res = domHtmlImplClass.newInstance();
+ }
+ catch (ClassNotFoundException ex)
+ {
+ // Return null if HTML parser cannot be found.
+ }
+ catch (IllegalAccessException ex)
+ {
+ // Return null if HTML parser cannot be found.
+ }
+ catch (InstantiationException ex)
+ {
+ // Return null if HTML parser cannot be found.
+ }
+ return res;
}
return this;
}
------------------------------------------------------------------------
_______________________________________________
Classpath-patches mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/classpath-patches