You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by di...@apache.org on 2001/08/25 16:17:56 UTC
cvs commit: jakarta-slide/src/util/org/apache/util DOMUtils.java
dirkv 01/08/25 07:17:56
Modified: src/util/org/apache/util DOMUtils.java
Log:
test if you get a namespace aware parser from JAXP
Revision Changes Path
1.3 +27 -4 jakarta-slide/src/util/org/apache/util/DOMUtils.java
Index: DOMUtils.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/util/org/apache/util/DOMUtils.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOMUtils.java 2001/05/15 16:53:40 1.2
+++ DOMUtils.java 2001/08/25 14:17:56 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/util/org/apache/util/DOMUtils.java,v 1.2 2001/05/15 16:53:40 jericho Exp $
- * $Revision: 1.2 $
- * $Date: 2001/05/15 16:53:40 $
+ * $Header: /home/cvs/jakarta-slide/src/util/org/apache/util/DOMUtils.java,v 1.3 2001/08/25 14:17:56 dirkv Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/08/25 14:17:56 $
*
* ====================================================================
*
@@ -67,12 +67,18 @@
import java.lang.reflect.Method;
import java.io.InputStream;
+import java.io.StringReader;
import java.io.IOException;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Vector;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.xml.sax.InputSource;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -89,13 +95,30 @@
*
* @author <a href="mailto:bcholmes@interlog.com>B.C. Holmes</a>
* @author <a href="mailto:jericho@thinkfree.com>Park, Sung-Gu</a>
- * @version $Revision: 1.2 $
+ * @author Dirk Verbeeck
+ * @version $Revision: 1.3 $
*/
public class DOMUtils {
protected static Class[] getElementsByNSParameterTypes =
{ String.class, String.class };
+
+ public static boolean isDocumentBuilderDOM2Compliant() {
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ String data="<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:propfind xmlns:D=\"DAV:\"><D:prop><D:displayname/></D:prop></D:propfind>";
+ Document document = builder.parse(new InputSource(new StringReader(data)));
+ Element root = document.getDocumentElement();
+ return isDOM2Compliant(root);
+ }
+ catch (Throwable ex) {
+ }
+ return false;
+ }
/**
* This method checks a DOM node to see if the implementation