Author: vgritsenko Date: Sun Nov 26 15:02:23 2006 New Revision: 479447 URL: http://svn.apache.org/viewvc?view=rev&rev=479447 Log: <action dev="VG" type="update" fixes-bug="41002" due-to="Natalia Shilenkova"> Ignore SAXNotSupportedException in DOMParser.setFeature if feature is being set to false. (Needed for Oracle 10g application server). </action>
Modified: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java xml/xindice/trunk/status.xml Modified: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java?view=diff&rev=479447&r1=479446&r2=479447 ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java Sun Nov 26 15:02:23 2006 @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * CVS $Id$ + * $Id$ */ package org.apache.xindice.xml.dom; @@ -33,6 +33,8 @@ import org.xml.sax.InputSource; import org.xml.sax.Locator; import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; import org.xml.sax.SAXParseException; import org.xml.sax.XMLReader; import org.xml.sax.ext.DeclHandler; @@ -41,6 +43,7 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -50,7 +53,7 @@ /** * DOMParser is the Xindice compressed DOM parser. * - * @version CVS $Revision$, $Date$ + * @version $Revision$, $Date$ */ public final class DOMParser extends DefaultHandler implements DeclHandler, LexicalHandler { @@ -190,11 +193,11 @@ private SAXParser getSAXParser() throws Exception { final SAXParser sp = factory.newSAXParser(); final XMLReader xr = sp.getXMLReader(); - xr.setFeature("http://xml.org/sax/features/namespaces", true); - xr.setFeature("http://xml.org/sax/features/validation", false); - xr.setFeature("http://xml.org/sax/features/external-general-entities", false); - xr.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - xr.setFeature("http://xml.org/sax/features/namespace-prefixes", true); + setFeature(xr, "http://xml.org/sax/features/namespaces", true); + setFeature(xr, "http://xml.org/sax/features/validation", false); + setFeature(xr, "http://xml.org/sax/features/external-general-entities", false); + setFeature(xr, "http://xml.org/sax/features/external-parameter-entities", false); + setFeature(xr, "http://xml.org/sax/features/namespace-prefixes", true); xr.setProperty("http://xml.org/sax/properties/lexical-handler", this); xr.setProperty("http://xml.org/sax/properties/declaration-handler", this); if (errors != null) { @@ -205,6 +208,30 @@ } return sp; + } + + /** + * Tries to set SAX features. It is assumed that feature support is required + * if its value is <em>true</em> and optional if the value is <em>false</em>. + * + * @param xr XMLReader + * @param name SAX feature name + * @param value feature value + * @throws SAXNotRecognizedException + * @throws SAXNotSupportedException if the SAX feature is not supported and + * the value is <em>true</em> + */ + private void setFeature(XMLReader xr, String name, boolean value) + throws SAXNotRecognizedException, SAXNotSupportedException { + try { + xr.setFeature(name, value); + } catch (SAXNotSupportedException e) { + if (value) { + throw e; + } else if (log.isWarnEnabled()) { + log.warn("SAX feature " + name + " is not supported"); + } + } } private void pushState(int newState) { Modified: xml/xindice/trunk/status.xml URL: http://svn.apache.org/viewvc/xml/xindice/trunk/status.xml?view=diff&rev=479447&r1=479446&r2=479447 ============================================================================== --- xml/xindice/trunk/status.xml (original) +++ xml/xindice/trunk/status.xml Sun Nov 26 15:02:23 2006 @@ -75,6 +75,10 @@ <changes> <release version="1.1b5-dev" date="Oct 27 2006"> + <action dev="VG" type="update" fixes-bug="41002" due-to="Natalia Shilenkova"> + Ignore SAXNotSupportedException in DOMParser.setFeature if + feature is being set to false. (Needed for Oracle 10g application server). + </action> <action dev="VG" type="update" fixes-bug="41003" due-to="Natalia Shilenkova"> Change InlineMetaReader.read() method signature to remove unnecessary data copying.