You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2006/09/01 06:31:21 UTC

svn commit: r439173 - /xerces/java/trunk/src/org/apache/xerces/jaxp/DocumentBuilderFactoryImpl.java

Author: mrglavas
Date: Thu Aug 31 21:31:20 2006
New Revision: 439173

URL: http://svn.apache.org/viewvc?rev=439173&view=rev
Log:
It was possible for an application to set features on the DocumentBuilderFactory
which have values that are inconsistent with the factory built-in settings.
This might mean the value they set gets ignored because the other instance
of the setting overwrites the first when the DocumentBuilder is initially
configured. The features and built-in settings are now kept in synch. This
may also improve performance for some applications since we're not always
creating a new parser to test whether a feature is recognized by the factory.

Modified:
    xerces/java/trunk/src/org/apache/xerces/jaxp/DocumentBuilderFactoryImpl.java

Modified: xerces/java/trunk/src/org/apache/xerces/jaxp/DocumentBuilderFactoryImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/jaxp/DocumentBuilderFactoryImpl.java?rev=439173&r1=439172&r2=439173&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/jaxp/DocumentBuilderFactoryImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/jaxp/DocumentBuilderFactoryImpl.java Thu Aug 31 21:31:20 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2002,2004,2005 The Apache Software Foundation.
+ * Copyright 2000-2002,2004-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.validation.Schema;
 
+import org.apache.xerces.impl.Constants;
 import org.apache.xerces.parsers.DOMParser;
 import org.apache.xerces.util.SAXMessageFormatter;
 import org.xml.sax.SAXException;
@@ -36,6 +37,35 @@
  * @version $Id$
  */
 public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory {
+    
+    /** Feature identifier: namespaces. */
+    private static final String NAMESPACES_FEATURE =
+        Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
+    
+    /** Feature identifier: validation */
+    private static final String VALIDATION_FEATURE =
+        Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
+    
+    /** Feature identifier: XInclude processing */
+    private static final String XINCLUDE_FEATURE = 
+        Constants.XERCES_FEATURE_PREFIX + Constants.XINCLUDE_FEATURE;
+    
+    /** Feature identifier: include ignorable white space. */
+    private static final String INCLUDE_IGNORABLE_WHITESPACE =
+        Constants.XERCES_FEATURE_PREFIX + Constants.INCLUDE_IGNORABLE_WHITESPACE;
+    
+    /** Feature identifier: create entiry ref nodes feature. */
+    private static final String CREATE_ENTITY_REF_NODES_FEATURE =
+        Constants.XERCES_FEATURE_PREFIX + Constants.CREATE_ENTITY_REF_NODES_FEATURE;
+    
+    /** Feature identifier: include comments feature. */
+    private static final String INCLUDE_COMMENTS_FEATURE =
+        Constants.XERCES_FEATURE_PREFIX + Constants.INCLUDE_COMMENTS_FEATURE;
+    
+    /** Feature identifier: create cdata nodes feature. */
+    private static final String CREATE_CDATA_NODES_FEATURE =
+        Constants.XERCES_FEATURE_PREFIX + Constants.CREATE_CDATA_NODES_FEATURE;
+    
     /** These are DocumentBuilderFactory attributes not DOM attributes */
     private Hashtable attributes;
     private Hashtable features;
@@ -169,6 +199,27 @@
         if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
             return fSecureProcess;
         }
+        else if (name.equals(NAMESPACES_FEATURE)) {
+            return isNamespaceAware();
+        }
+        else if (name.equals(VALIDATION_FEATURE)) {
+            return isValidating();
+        }
+        else if (name.equals(XINCLUDE_FEATURE)) {
+            return isXIncludeAware();
+        }
+        else if (name.equals(INCLUDE_IGNORABLE_WHITESPACE)) {
+            return !isIgnoringElementContentWhitespace();
+        }
+        else if (name.equals(CREATE_ENTITY_REF_NODES_FEATURE)) {
+            return !isExpandEntityReferences();
+        }
+        else if (name.equals(INCLUDE_COMMENTS_FEATURE)) {
+            return !isIgnoringComments();
+        }
+        else if (name.equals(CREATE_CDATA_NODES_FEATURE)) {
+            return !isCoalescing();
+        }
         // See if it's in the features Hashtable
         if (features != null) {
             Object val = features.get(name);
@@ -192,6 +243,36 @@
             fSecureProcess = value;
             return;
         }
+        // Keep built-in settings in synch with the feature values.
+        else if (name.equals(NAMESPACES_FEATURE)) {
+            setNamespaceAware(value);
+            return;
+        }
+        else if (name.equals(VALIDATION_FEATURE)) {
+            setValidating(value);
+            return;
+        }
+        else if (name.equals(XINCLUDE_FEATURE)) {
+            setXIncludeAware(value);
+            return;
+        }
+        else if (name.equals(INCLUDE_IGNORABLE_WHITESPACE)) {
+            setIgnoringElementContentWhitespace(!value);
+            return;
+        }
+        else if (name.equals(CREATE_ENTITY_REF_NODES_FEATURE)) {
+            setExpandEntityReferences(!value);
+            return;
+        }
+        else if (name.equals(INCLUDE_COMMENTS_FEATURE)) {
+            setIgnoringComments(!value);
+            return;
+        }
+        else if (name.equals(CREATE_CDATA_NODES_FEATURE)) {
+            setCoalescing(!value);
+            return;
+        }
+           
         if (features == null) {
             features = new Hashtable();
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org