Index: org/apache/xerces/dom/DOMImplementationSourceImpl.java =================================================================== retrieving revision 1.14 diff -u -r1.14 DOMImplementationSourceImpl.java --- org/apache/xerces/dom/DOMImplementationSourceImpl.java 24 Feb 2004 23:23:18 -0000 1.14 +++ org/apache/xerces/dom/DOMImplementationSourceImpl.java 22 Apr 2004 16:06:21 -0000 @@ -17,11 +17,11 @@ package org.apache.xerces.dom; import java.util.StringTokenizer; - +import java.util.Vector; import org.apache.xerces.dom3.DOMImplementationList; import org.apache.xerces.dom3.DOMImplementationSource; -import org.apache.xerces.dom3.bootstrap.DOMImplementationListImpl; import org.w3c.dom.DOMImplementation; +import org.apache.xerces.dom.DOMImplementationListImpl; /** * Supply one the right implementation, based upon requested features. Each @@ -29,7 +29,7 @@ * binding-specific list of available sources so that its * DOMImplementation objects are made available. * - *

See also the Document Object Model (DOM) Level 3 Core Specification. + *

See also the Document Object Model (DOM) Level 3 Core Specification. * * @version $Id: DOMImplementationSourceImpl.java,v 1.14 2004/02/24 23:23:18 mrglavas Exp $ */ @@ -57,14 +57,11 @@ if (testImpl(impl, features)) { return impl; } - return null; } /** - * DOM Level 3 Core - CR - * * A method to request a list of DOM implementations that support the * specified features and versions, as specified in . * @param features A string that specifies which features and versions @@ -78,17 +75,16 @@ public DOMImplementationList getDOMImplementationList(String features) { // first check whether the CoreDOMImplementation would do DOMImplementation impl = CoreDOMImplementationImpl.getDOMImplementation(); - DOMImplementationListImpl list = new DOMImplementationListImpl(); + final Vector implementations = new Vector(); if (testImpl(impl, features)) { - list.add(impl); + implementations.addElement(impl); } impl = DOMImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { - list.add(impl); + implementations.addElement(impl); } - - return list; + return (DOMImplementationList) new DOMImplementationListImpl(implementations); } boolean testImpl(DOMImplementation impl, String features) { Index: org/apache/xerces/dom/DOMXSImplementationSourceImpl.java =================================================================== retrieving revision 1.2 diff -u -r1.2 DOMXSImplementationSourceImpl.java --- org/apache/xerces/dom/DOMXSImplementationSourceImpl.java 24 Feb 2004 23:23:18 -0000 1.2 +++ org/apache/xerces/dom/DOMXSImplementationSourceImpl.java 22 Apr 2004 16:06:21 -0000 @@ -16,21 +16,22 @@ package org.apache.xerces.dom; -import org.apache.xerces.dom3.DOMImplementationList; -import org.apache.xerces.dom3.bootstrap.DOMImplementationListImpl; import org.apache.xerces.impl.xs.XSImplementationImpl; +import org.apache.xerces.dom3.DOMImplementationList; +import org.apache.xerces.dom3.DOMImplementationSource; import org.w3c.dom.DOMImplementation; +import java.util.Vector; /** * Allows to retrieve XSImplementation, DOM Level 3 Core and LS implementations * and PSVI implementation. - *

See also the Document Object Model (DOM) Level 3 Core Specification. + *

See also the Document Object Model (DOM) Level 3 Core Specification. * @author Elena Litani, IBM * @version $Id: DOMXSImplementationSourceImpl.java,v 1.2 2004/02/24 23:23:18 mrglavas Exp $ */ public class DOMXSImplementationSourceImpl - extends DOMImplementationSourceImpl{ - +extends DOMImplementationSourceImpl { + /** * A method to request a DOM implementation. * @param features A string that specifies which features are required. @@ -43,25 +44,23 @@ public DOMImplementation getDOMImplementation(String features) { DOMImplementation impl = super.getDOMImplementation(features); if (impl != null){ - return impl; + return impl; + } + // if not try the PSVIDOMImplementation + impl = PSVIDOMImplementationImpl.getDOMImplementation(); + if (testImpl(impl, features)) { + return impl; + } + // if not try the XSImplementation + impl = XSImplementationImpl.getDOMImplementation(); + if (testImpl(impl, features)) { + return impl; } - // if not try the PSVIDOMImplementation - impl = PSVIDOMImplementationImpl.getDOMImplementation(); - if (testImpl(impl, features)) { - return impl; - } - // if not try the XSImplementation - impl = XSImplementationImpl.getDOMImplementation(); - if (testImpl(impl, features)) { - return impl; - } return null; } /** - * DOM Level 3 Core - CR - * * A method to request a list of DOM implementations that support the * specified features and versions, as specified in . * @param features A string that specifies which features and versions @@ -73,18 +72,24 @@ * features. */ public DOMImplementationList getDOMImplementationList(String features) { + final Vector implementations = new Vector(); + // first check whether the CoreDOMImplementation would do - DOMImplementationListImpl list = (DOMImplementationListImpl)super.getDOMImplementationList(features); - DOMImplementation impl = PSVIDOMImplementationImpl.getDOMImplementation(); - if (testImpl(impl, features)) { - list.add(impl); - } + DOMImplementationList list = super.getDOMImplementationList(features); + //Add core DOMImplementations + for (int i=0; i < list.getLength(); i++ ) { + implementations.addElement(list.item(i)); + } - impl = XSImplementationImpl.getDOMImplementation(); + DOMImplementation impl = PSVIDOMImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { - list.add(impl); + implementations.addElement(impl); } - return list; + + impl = XSImplementationImpl.getDOMImplementation(); + if (testImpl(impl, features)) { + implementations.addElement(impl); + } + return (DOMImplementationList) new DOMImplementationListImpl(implementations); } - } Index: src/org/apache/xerces/dom/DOMImplementationListImpl.java =================================================================== RCS file: src/org/apache/xerces/dom/DOMImplementationListImpl.java diff -N src/org/apache/xerces/dom/DOMImplementationListImpl.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/apache/xerces/dom/DOMImplementationListImpl.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,69 @@ +/* + * Copyright 2004 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.xerces.dom; + +import java.util.Vector; +import org.apache.xerces.dom3.DOMImplementationList; +import org.w3c.dom.DOMImplementation; + +/** + *

This class implements the DOM Level 3 Core interface DOMImplementationList.

+ * + * @author Neil Delima, IBM + * @since DOM Level 3 Core + */ +public class DOMImplementationListImpl implements DOMImplementationList { + + //A collection of DOMImplementations + private Vector fImplementations; + + /** + * Construct an empty list of DOMImplementations + */ + public DOMImplementationListImpl() { + fImplementations = new Vector(); + } + + /** + * Construct an empty list of DOMImplementations + */ + public DOMImplementationListImpl(Vector params) { + fImplementations = params; + } + + /** + * Returns the indexth item in the collection. + * + * @param index The index of the DOMImplemetation from the list to return. + */ + public DOMImplementation item(int index) { + try { + return (DOMImplementation) fImplementations.elementAt(index); + } catch (ArrayIndexOutOfBoundsException e) { + return null; + } + } + + /** + * Returns the number of DOMImplementations in the list. + * + * @return An integer indicating the number of DOMImplementations. + */ + public int getLength() { + return fImplementations.size(); + } +}