2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.xerces.impl.xs;
20
import org.apache.xerces.dom.CoreDOMImplementationImpl;
21
import org.apache.xerces.dom.DOMMessageFormatter;
22
import org.apache.xerces.impl.xs.util.StringListImpl;
23
import org.apache.xerces.xs.StringList;
24
import org.apache.xerces.xs.XSException;
25
import org.apache.xerces.xs.XSImplementation;
26
import org.apache.xerces.xs.XSLoader;
27
import org.w3c.dom.DOMImplementation;
31
* Implements XSImplementation interface that allows one to retrieve an instance of <code>XSLoader</code>.
32
* This interface should be implemented on the same object that implements
37
* @author Elena Litani, IBM
38
* @version $Id: XSImplementationImpl.java,v 1.2 2009/12/10 03:18:27 matthewoliver Exp $
40
public class XSImplementationImpl extends CoreDOMImplementationImpl
41
implements XSImplementation {
49
/** Dom implementation singleton. */
50
static XSImplementationImpl singleton = new XSImplementationImpl();
56
/** NON-DOM: Obtain and return the single shared object */
57
public static DOMImplementation getDOMImplementation() {
62
// DOMImplementation methods
66
* Test if the DOM implementation supports a specific "feature" --
67
* currently meaning language and level thereof.
69
* @param feature The package name of the feature to test.
70
* In Level 1, supported values are "HTML" and "XML" (case-insensitive).
71
* At this writing, org.apache.xerces.dom supports only XML.
73
* @param version The version number of the feature being tested.
74
* This is interpreted as "Version of the DOM API supported for the
75
* specified Feature", and in Level 1 should be "1.0"
77
* @return true iff this implementation is compatable with the specified
78
* feature and version.
80
public boolean hasFeature(String feature, String version) {
82
return (feature.equalsIgnoreCase("XS-Loader") && (version == null || version.equals("1.0")) ||
83
super.hasFeature(feature, version));
84
} // hasFeature(String,String):boolean
89
* @see org.apache.xerces.xs.XSImplementation#createXSLoader(org.apache.xerces.xs.StringList)
91
public XSLoader createXSLoader(StringList versions) throws XSException {
92
XSLoader loader = new XSLoaderImpl();
93
if (versions == null){
96
for (int i=0; i<versions.getLength();i++){
97
if (!versions.item(i).equals("1.0")){
99
DOMMessageFormatter.formatMessage(
100
DOMMessageFormatter.DOM_DOMAIN,
101
"FEATURE_NOT_SUPPORTED",
102
new Object[] { versions.item(i) });
103
throw new XSException(XSException.NOT_SUPPORTED_ERR, msg);
110
* @see org.apache.xerces.xs.XSImplementation#getRecognizedVersions()
112
public StringList getRecognizedVersions() {
113
StringListImpl list = new StringListImpl(new String[]{"1.0"}, 1);
117
} // class XSImplementationImpl