jaxp/src/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 6 7f561c08de6b
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     6
 * Copyright 1999-2005 The Apache Software Foundation.
7f561c08de6b Initial load
duke
parents:
diff changeset
     7
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
     8
 * Licensed under the Apache License, Version 2.0 (the "License");
7f561c08de6b Initial load
duke
parents:
diff changeset
     9
 * you may not use this file except in compliance with the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    10
 * You may obtain a copy of the License at
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *      http://www.apache.org/licenses/LICENSE-2.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
package com.sun.org.apache.xerces.internal.dom;
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
import com.sun.org.apache.xerces.internal.impl.RevalidationHandler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
import com.sun.org.apache.xerces.internal.parsers.DOMParserImpl;
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
import com.sun.org.apache.xerces.internal.util.XMLChar;
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
import org.w3c.dom.DOMException;
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import org.w3c.dom.DOMImplementation;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
import org.w3c.dom.Document;
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
import org.w3c.dom.DocumentType;
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
import org.w3c.dom.Element;
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
import org.w3c.dom.ls.LSParser;
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
import org.w3c.dom.ls.DOMImplementationLS;
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
import org.w3c.dom.ls.LSInput;
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
import org.w3c.dom.ls.LSOutput;
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
import org.w3c.dom.ls.LSSerializer;
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
 * The DOMImplementation class is description of a particular
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
 * implementation of the Document Object Model. As such its data is
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
 * static, shared by all instances of this implementation.
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 * <P>
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * The DOM API requires that it be a real object rather than static
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 * methods. However, there's nothing that says it can't be a singleton,
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 * so that's how I've implemented it.
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 * <P>
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
 * This particular class, along with CoreDocumentImpl, supports the DOM
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
 * Core and Load/Save (Experimental). Optional modules are supported by
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
 * the more complete DOMImplementation class along with DocumentImpl.
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
 * @xerces.internal
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
 * @since PR-DOM-Level-1-19980818.
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
public class CoreDOMImplementationImpl
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
        implements DOMImplementation, DOMImplementationLS {
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
        //
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
        // Data
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
        //
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
    // validators pool
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
    private static final int SIZE = 2;
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
    private RevalidationHandler validators[] = new RevalidationHandler[SIZE];
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
    private RevalidationHandler dtdValidators[] = new RevalidationHandler[SIZE];
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
    private int freeValidatorIndex = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
    private int freeDTDValidatorIndex = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
    private int currentSize = SIZE;
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
    // Document and doctype counter.  Used to assign order to documents and
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
    // doctypes without owners, on an demand basis.   Used for
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
    // compareDocumentPosition
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
    private int docAndDoctypeCounter = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
        // static
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
        /** Dom implementation singleton. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
        static CoreDOMImplementationImpl singleton =
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
                new CoreDOMImplementationImpl();
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
        //
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
        // Public methods
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
        //
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
        /** NON-DOM: Obtain and return the single shared object */
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
        public static DOMImplementation getDOMImplementation() {
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
                return singleton;
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
        //
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
        // DOMImplementation methods
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
        //
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
         * Test if the DOM implementation supports a specific "feature" --
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
         * currently meaning language and level thereof.
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
         * @param feature The package name of the feature to test.
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
         * In Level 1, supported values are "HTML" and "XML" (case-insensitive).
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
         * At this writing, com.sun.org.apache.xerces.internal.dom supports only XML.
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
         * @param version The version number of the feature being tested.
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
         * This is interpreted as "Version of the DOM API supported for the
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
         * specified Feature", and in Level 1 should be "1.0"
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
         * @return true iff this implementation is compatable with the specified
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
         * feature and version.
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
        public boolean hasFeature(String feature, String version) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
            boolean anyVersion = version == null || version.length() == 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
            // check if Xalan implementation is around and if yes report true for supporting
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
            // XPath API
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
            // if a plus sign "+" is prepended to any feature name, implementations
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
            // are considered in which the specified feature may not be directly
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
            // castable DOMImplementation.getFeature(feature, version). Without a
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
            // plus, only features whose interfaces are directly castable are considered.
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
            if ((feature.equalsIgnoreCase("+XPath"))
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
                && (anyVersion || version.equals("3.0"))) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
                try {
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
                    Class xpathClass = ObjectFactory.findProviderClass(
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
                        "com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl",
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
                        ObjectFactory.findClassLoader(), true);
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
                // Check if the DOM XPath implementation implements
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
                // the interface org.w3c.dom.XPathEvaluator
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
                Class interfaces[] = xpathClass.getInterfaces();
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
                for (int i = 0; i < interfaces.length; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
                    if (interfaces[i].getName().equals(
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
                        "org.w3c.dom.xpath.XPathEvaluator")) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
                        return true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
                    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
                } catch (Exception e) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
                    return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
                return true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
            if (feature.startsWith("+")) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
                feature = feature.substring(1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
            return (
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
                feature.equalsIgnoreCase("Core")
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
                    && (anyVersion
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
                        || version.equals("1.0")
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
                        || version.equals("2.0")
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
                        || version.equals("3.0")))
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
                        || (feature.equalsIgnoreCase("XML")
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
                    && (anyVersion
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
                        || version.equals("1.0")
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
                        || version.equals("2.0")
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
                        || version.equals("3.0")))
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
                        || (feature.equalsIgnoreCase("LS")
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
                    && (anyVersion || version.equals("3.0")));
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
        } // hasFeature(String,String):boolean
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
         * Introduced in DOM Level 2. <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
         * Creates an empty DocumentType node.
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
         * @param qualifiedName The qualified name of the document type to be created.
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
         * @param publicID The document type public identifier.
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
         * @param systemID The document type system identifier.
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
         * @since WD-DOM-Level-2-19990923
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
        public DocumentType createDocumentType( String qualifiedName,
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
                                    String publicID, String systemID) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
                // REVISIT: this might allow creation of invalid name for DOCTYPE
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
                //          xmlns prefix.
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
                //          also there is no way for a user to turn off error checking.
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
                checkQName(qualifiedName);
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
                return new DocumentTypeImpl(null, qualifiedName, publicID, systemID);
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
    final void checkQName(String qname){
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
        int index = qname.indexOf(':');
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
        int lastIndex = qname.lastIndexOf(':');
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
        int length = qname.length();
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
        // it is an error for NCName to have more than one ':'
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
        // check if it is valid QName [Namespace in XML production 6]
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
        if (index == 0 || index == length - 1 || lastIndex != index) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
            String msg =
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
                DOMMessageFormatter.formatMessage(
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
                    DOMMessageFormatter.DOM_DOMAIN,
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
                    "NAMESPACE_ERR",
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
                    null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
            throw new DOMException(DOMException.NAMESPACE_ERR, msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
        int start = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
        // Namespace in XML production [6]
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
        if (index > 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
            // check that prefix is NCName
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
            if (!XMLChar.isNCNameStart(qname.charAt(start))) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
                String msg =
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
                    DOMMessageFormatter.formatMessage(
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
                        DOMMessageFormatter.DOM_DOMAIN,
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
                        "INVALID_CHARACTER_ERR",
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
                        null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
                throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
            for (int i = 1; i < index; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
                if (!XMLChar.isNCName(qname.charAt(i))) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
                    String msg =
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
                        DOMMessageFormatter.formatMessage(
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
                            DOMMessageFormatter.DOM_DOMAIN,
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
                            "INVALID_CHARACTER_ERR",
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
                            null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
                    throw new DOMException(
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
                        DOMException.INVALID_CHARACTER_ERR,
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
                        msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
            start = index + 1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
        // check local part
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
        if (!XMLChar.isNCNameStart(qname.charAt(start))) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
            // REVISIT: add qname parameter to the message
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
            String msg =
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
                DOMMessageFormatter.formatMessage(
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
                    DOMMessageFormatter.DOM_DOMAIN,
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
                    "INVALID_CHARACTER_ERR",
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
                    null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
            throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
        for (int i = start + 1; i < length; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
            if (!XMLChar.isNCName(qname.charAt(i))) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
                String msg =
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
                    DOMMessageFormatter.formatMessage(
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
                        DOMMessageFormatter.DOM_DOMAIN,
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
                        "INVALID_CHARACTER_ERR",
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
                        null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
                throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
         * Introduced in DOM Level 2. <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
         * Creates an XML Document object of the specified type with its document
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
         * element.
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
         * @param namespaceURI     The namespace URI of the document
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
         *                         element to create, or null.
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
         * @param qualifiedName    The qualified name of the document
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
         *                         element to create.
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
         * @param doctype          The type of document to be created or null.<p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
         *
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
         *                         When doctype is not null, its
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
         *                         Node.ownerDocument attribute is set to
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
         *                         the document being created.
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
         * @return Document        A new Document object.
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
         * @throws DOMException    WRONG_DOCUMENT_ERR: Raised if doctype has
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
         *                         already been used with a different document.
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
         * @since WD-DOM-Level-2-19990923
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
        public Document createDocument(
7f561c08de6b Initial load
duke
parents:
diff changeset
   258
                String namespaceURI,
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
                String qualifiedName,
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
                DocumentType doctype)
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
                throws DOMException {
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
                if (doctype != null && doctype.getOwnerDocument() != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
                        String msg =
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
                                DOMMessageFormatter.formatMessage(
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
                                        DOMMessageFormatter.DOM_DOMAIN,
7f561c08de6b Initial load
duke
parents:
diff changeset
   266
                                        "WRONG_DOCUMENT_ERR",
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
                                        null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
                        throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   269
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   270
                CoreDocumentImpl doc = new CoreDocumentImpl(doctype);
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
                Element e = doc.createElementNS(namespaceURI, qualifiedName);
7f561c08de6b Initial load
duke
parents:
diff changeset
   272
                doc.appendChild(e);
7f561c08de6b Initial load
duke
parents:
diff changeset
   273
                return doc;
7f561c08de6b Initial load
duke
parents:
diff changeset
   274
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   275
7f561c08de6b Initial load
duke
parents:
diff changeset
   276
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   277
         * DOM Level 3 WD - Experimental.
7f561c08de6b Initial load
duke
parents:
diff changeset
   278
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   279
        public Object getFeature(String feature, String version) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   280
            if (singleton.hasFeature(feature, version)) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   281
                if ((feature.equalsIgnoreCase("+XPath"))) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   282
                    try {
7f561c08de6b Initial load
duke
parents:
diff changeset
   283
                        Class xpathClass = ObjectFactory.findProviderClass(
7f561c08de6b Initial load
duke
parents:
diff changeset
   284
                            "com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl",
7f561c08de6b Initial load
duke
parents:
diff changeset
   285
                            ObjectFactory.findClassLoader(), true);
7f561c08de6b Initial load
duke
parents:
diff changeset
   286
7f561c08de6b Initial load
duke
parents:
diff changeset
   287
                        // Check if the DOM XPath implementation implements
7f561c08de6b Initial load
duke
parents:
diff changeset
   288
                        // the interface org.w3c.dom.XPathEvaluator
7f561c08de6b Initial load
duke
parents:
diff changeset
   289
                        Class interfaces[] = xpathClass.getInterfaces();
7f561c08de6b Initial load
duke
parents:
diff changeset
   290
                        for (int i = 0; i < interfaces.length; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   291
                            if (interfaces[i].getName().equals(
7f561c08de6b Initial load
duke
parents:
diff changeset
   292
                                "org.w3c.dom.xpath.XPathEvaluator")) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   293
                                return xpathClass.newInstance();
7f561c08de6b Initial load
duke
parents:
diff changeset
   294
                            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   295
                        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   296
                    } catch (Exception e) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   297
                        return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   298
                    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   299
                } else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   300
                    return singleton;
7f561c08de6b Initial load
duke
parents:
diff changeset
   301
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   302
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   303
            return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   304
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   305
7f561c08de6b Initial load
duke
parents:
diff changeset
   306
        // DOM L3 LS
7f561c08de6b Initial load
duke
parents:
diff changeset
   307
7f561c08de6b Initial load
duke
parents:
diff changeset
   308
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   309
         * DOM Level 3 LS CR - Experimental.
7f561c08de6b Initial load
duke
parents:
diff changeset
   310
     * Create a new <code>LSParser</code>. The newly constructed parser may
7f561c08de6b Initial load
duke
parents:
diff changeset
   311
     * then be configured by means of its <code>DOMConfiguration</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   312
     * object, and used to parse documents by means of its <code>parse</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   313
     *  method.
7f561c08de6b Initial load
duke
parents:
diff changeset
   314
     * @param mode  The <code>mode</code> argument is either
7f561c08de6b Initial load
duke
parents:
diff changeset
   315
     *   <code>MODE_SYNCHRONOUS</code> or <code>MODE_ASYNCHRONOUS</code>, if
7f561c08de6b Initial load
duke
parents:
diff changeset
   316
     *   <code>mode</code> is <code>MODE_SYNCHRONOUS</code> then the
7f561c08de6b Initial load
duke
parents:
diff changeset
   317
     *   <code>LSParser</code> that is created will operate in synchronous
7f561c08de6b Initial load
duke
parents:
diff changeset
   318
     *   mode, if it's <code>MODE_ASYNCHRONOUS</code> then the
7f561c08de6b Initial load
duke
parents:
diff changeset
   319
     *   <code>LSParser</code> that is created will operate in asynchronous
7f561c08de6b Initial load
duke
parents:
diff changeset
   320
     *   mode.
7f561c08de6b Initial load
duke
parents:
diff changeset
   321
     * @param schemaType  An absolute URI representing the type of the schema
7f561c08de6b Initial load
duke
parents:
diff changeset
   322
     *   language used during the load of a <code>Document</code> using the
7f561c08de6b Initial load
duke
parents:
diff changeset
   323
     *   newly created <code>LSParser</code>. Note that no lexical checking
7f561c08de6b Initial load
duke
parents:
diff changeset
   324
     *   is done on the absolute URI. In order to create a
7f561c08de6b Initial load
duke
parents:
diff changeset
   325
     *   <code>LSParser</code> for any kind of schema types (i.e. the
7f561c08de6b Initial load
duke
parents:
diff changeset
   326
     *   LSParser will be free to use any schema found), use the value
7f561c08de6b Initial load
duke
parents:
diff changeset
   327
     *   <code>null</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   328
     * <p ><b>Note:</b>    For W3C XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
7f561c08de6b Initial load
duke
parents:
diff changeset
   329
     *   , applications must use the value
7f561c08de6b Initial load
duke
parents:
diff changeset
   330
     *   <code>"http://www.w3.org/2001/XMLSchema"</code>. For XML DTD [<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>],
7f561c08de6b Initial load
duke
parents:
diff changeset
   331
     *   applications must use the value
7f561c08de6b Initial load
duke
parents:
diff changeset
   332
     *   <code>"http://www.w3.org/TR/REC-xml"</code>. Other Schema languages
7f561c08de6b Initial load
duke
parents:
diff changeset
   333
     *   are outside the scope of the W3C and therefore should recommend an
7f561c08de6b Initial load
duke
parents:
diff changeset
   334
     *   absolute URI in order to use this method.
7f561c08de6b Initial load
duke
parents:
diff changeset
   335
     * @return  The newly created <code>LSParser</code> object. This
7f561c08de6b Initial load
duke
parents:
diff changeset
   336
     *   <code>LSParser</code> is either synchronous or asynchronous
7f561c08de6b Initial load
duke
parents:
diff changeset
   337
     *   depending on the value of the <code>mode</code> argument.
7f561c08de6b Initial load
duke
parents:
diff changeset
   338
     * <p ><b>Note:</b>    By default, the newly created <code>LSParser</code>
7f561c08de6b Initial load
duke
parents:
diff changeset
   339
     *    does not contain a <code>DOMErrorHandler</code>, i.e. the value of
7f561c08de6b Initial load
duke
parents:
diff changeset
   340
     *   the "<a href='http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#parameter-error-handler'>
7f561c08de6b Initial load
duke
parents:
diff changeset
   341
     *   error-handler</a>" configuration parameter is <code>null</code>. However, implementations
7f561c08de6b Initial load
duke
parents:
diff changeset
   342
     *   may provide a default error handler at creation time. In that case,
7f561c08de6b Initial load
duke
parents:
diff changeset
   343
     *   the initial value of the <code>"error-handler"</code> configuration
7f561c08de6b Initial load
duke
parents:
diff changeset
   344
     *   parameter on the new created <code>LSParser</code> contains a
7f561c08de6b Initial load
duke
parents:
diff changeset
   345
     *   reference to the default error handler.
7f561c08de6b Initial load
duke
parents:
diff changeset
   346
     * @exception DOMException
7f561c08de6b Initial load
duke
parents:
diff changeset
   347
     *    NOT_SUPPORTED_ERR: Raised if the requested mode or schema type is
7f561c08de6b Initial load
duke
parents:
diff changeset
   348
     *   not supported.
7f561c08de6b Initial load
duke
parents:
diff changeset
   349
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   350
        public LSParser createLSParser(short mode, String schemaType)
7f561c08de6b Initial load
duke
parents:
diff changeset
   351
                throws DOMException {
7f561c08de6b Initial load
duke
parents:
diff changeset
   352
                if (mode != DOMImplementationLS.MODE_SYNCHRONOUS || (schemaType !=null &&
7f561c08de6b Initial load
duke
parents:
diff changeset
   353
                   !"http://www.w3.org/2001/XMLSchema".equals(schemaType) &&
7f561c08de6b Initial load
duke
parents:
diff changeset
   354
                        !"http://www.w3.org/TR/REC-xml".equals(schemaType))) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   355
                        String msg =
7f561c08de6b Initial load
duke
parents:
diff changeset
   356
                                DOMMessageFormatter.formatMessage(
7f561c08de6b Initial load
duke
parents:
diff changeset
   357
                                        DOMMessageFormatter.DOM_DOMAIN,
7f561c08de6b Initial load
duke
parents:
diff changeset
   358
                                        "NOT_SUPPORTED_ERR",
7f561c08de6b Initial load
duke
parents:
diff changeset
   359
                                        null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   360
                        throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   361
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   362
                if (schemaType != null
7f561c08de6b Initial load
duke
parents:
diff changeset
   363
                        && schemaType.equals("http://www.w3.org/TR/REC-xml")) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   364
                        return new DOMParserImpl(
7f561c08de6b Initial load
duke
parents:
diff changeset
   365
                                "com.sun.org.apache.xerces.internal.parsers.DTDConfiguration",
7f561c08de6b Initial load
duke
parents:
diff changeset
   366
                                schemaType);
7f561c08de6b Initial load
duke
parents:
diff changeset
   367
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   368
                else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   369
                        // create default parser configuration validating against XMLSchemas
7f561c08de6b Initial load
duke
parents:
diff changeset
   370
                        return new DOMParserImpl(
7f561c08de6b Initial load
duke
parents:
diff changeset
   371
                                "com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration",
7f561c08de6b Initial load
duke
parents:
diff changeset
   372
                                schemaType);
7f561c08de6b Initial load
duke
parents:
diff changeset
   373
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   374
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   375
7f561c08de6b Initial load
duke
parents:
diff changeset
   376
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   377
         * DOM Level 3 LS CR - Experimental.
7f561c08de6b Initial load
duke
parents:
diff changeset
   378
         * Create a new <code>LSSerializer</code> object.
7f561c08de6b Initial load
duke
parents:
diff changeset
   379
         * @return The newly created <code>LSSerializer</code> object.
7f561c08de6b Initial load
duke
parents:
diff changeset
   380
         * <p ><b>Note:</b>    By default, the newly created
7f561c08de6b Initial load
duke
parents:
diff changeset
   381
         * <code>LSSerializer</code> has no <code>DOMErrorHandler</code>,
7f561c08de6b Initial load
duke
parents:
diff changeset
   382
         * i.e. the value of the <code>"error-handler"</code> configuration
7f561c08de6b Initial load
duke
parents:
diff changeset
   383
         * parameter is <code>null</code>. However, implementations may
7f561c08de6b Initial load
duke
parents:
diff changeset
   384
         * provide a default error handler at creation time. In that case, the
7f561c08de6b Initial load
duke
parents:
diff changeset
   385
         * initial value of the <code>"error-handler"</code> configuration
7f561c08de6b Initial load
duke
parents:
diff changeset
   386
         * parameter on the new created <code>LSSerializer</code> contains a
7f561c08de6b Initial load
duke
parents:
diff changeset
   387
         * reference to the default error handler.
7f561c08de6b Initial load
duke
parents:
diff changeset
   388
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   389
        public LSSerializer createLSSerializer() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   390
        return new DOMSerializerImpl();
7f561c08de6b Initial load
duke
parents:
diff changeset
   391
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   392
        /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   393
         * DOM Level 3 LS CR - Experimental.
7f561c08de6b Initial load
duke
parents:
diff changeset
   394
         * Create a new empty input source.
7f561c08de6b Initial load
duke
parents:
diff changeset
   395
         * @return  The newly created input object.
7f561c08de6b Initial load
duke
parents:
diff changeset
   396
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   397
        public LSInput createLSInput() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   398
                return new DOMInputImpl();
7f561c08de6b Initial load
duke
parents:
diff changeset
   399
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   400
7f561c08de6b Initial load
duke
parents:
diff changeset
   401
        //
7f561c08de6b Initial load
duke
parents:
diff changeset
   402
        // Protected methods
7f561c08de6b Initial load
duke
parents:
diff changeset
   403
        //
7f561c08de6b Initial load
duke
parents:
diff changeset
   404
        /** NON-DOM: retrieve validator. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   405
        synchronized RevalidationHandler getValidator(String schemaType) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   406
                // REVISIT: implement retrieving DTD validator
7f561c08de6b Initial load
duke
parents:
diff changeset
   407
        if (schemaType == XMLGrammarDescription.XML_SCHEMA) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   408
            // create new validator - we should not attempt
7f561c08de6b Initial load
duke
parents:
diff changeset
   409
            // to restrict the number of validation handlers being
7f561c08de6b Initial load
duke
parents:
diff changeset
   410
            // requested
7f561c08de6b Initial load
duke
parents:
diff changeset
   411
            if(freeValidatorIndex < 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   412
                return (RevalidationHandler) (ObjectFactory
7f561c08de6b Initial load
duke
parents:
diff changeset
   413
                            .newInstance(
7f561c08de6b Initial load
duke
parents:
diff changeset
   414
                                "com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator",
7f561c08de6b Initial load
duke
parents:
diff changeset
   415
                                ObjectFactory.findClassLoader(),
7f561c08de6b Initial load
duke
parents:
diff changeset
   416
                                true));
7f561c08de6b Initial load
duke
parents:
diff changeset
   417
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   418
            // return first available validator
7f561c08de6b Initial load
duke
parents:
diff changeset
   419
            RevalidationHandler val = validators[freeValidatorIndex];
7f561c08de6b Initial load
duke
parents:
diff changeset
   420
            validators[freeValidatorIndex--] = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   421
            return val;
7f561c08de6b Initial load
duke
parents:
diff changeset
   422
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   423
        else if(schemaType == XMLGrammarDescription.XML_DTD) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   424
            if(freeDTDValidatorIndex < 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   425
                return (RevalidationHandler) (ObjectFactory
7f561c08de6b Initial load
duke
parents:
diff changeset
   426
                            .newInstance(
7f561c08de6b Initial load
duke
parents:
diff changeset
   427
                                "com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator",
7f561c08de6b Initial load
duke
parents:
diff changeset
   428
                                ObjectFactory.findClassLoader(),
7f561c08de6b Initial load
duke
parents:
diff changeset
   429
                                true));
7f561c08de6b Initial load
duke
parents:
diff changeset
   430
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   431
            // return first available validator
7f561c08de6b Initial load
duke
parents:
diff changeset
   432
            RevalidationHandler val = dtdValidators[freeDTDValidatorIndex];
7f561c08de6b Initial load
duke
parents:
diff changeset
   433
            dtdValidators[freeDTDValidatorIndex--] = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   434
            return val;
7f561c08de6b Initial load
duke
parents:
diff changeset
   435
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   436
        return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   437
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   438
7f561c08de6b Initial load
duke
parents:
diff changeset
   439
        /** NON-DOM: release validator */
7f561c08de6b Initial load
duke
parents:
diff changeset
   440
        synchronized void releaseValidator(String schemaType,
7f561c08de6b Initial load
duke
parents:
diff changeset
   441
                                         RevalidationHandler validator) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   442
       // REVISIT: implement support for DTD validators as well
7f561c08de6b Initial load
duke
parents:
diff changeset
   443
       if(schemaType == XMLGrammarDescription.XML_SCHEMA) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   444
           ++freeValidatorIndex;
7f561c08de6b Initial load
duke
parents:
diff changeset
   445
           if (validators.length == freeValidatorIndex ){
7f561c08de6b Initial load
duke
parents:
diff changeset
   446
                // resize size of the validators
7f561c08de6b Initial load
duke
parents:
diff changeset
   447
                currentSize+=SIZE;
7f561c08de6b Initial load
duke
parents:
diff changeset
   448
                RevalidationHandler newarray[] =  new RevalidationHandler[currentSize];
7f561c08de6b Initial load
duke
parents:
diff changeset
   449
                System.arraycopy(validators, 0, newarray, 0, validators.length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   450
                validators = newarray;
7f561c08de6b Initial load
duke
parents:
diff changeset
   451
           }
7f561c08de6b Initial load
duke
parents:
diff changeset
   452
           validators[freeValidatorIndex]=validator;
7f561c08de6b Initial load
duke
parents:
diff changeset
   453
       }
7f561c08de6b Initial load
duke
parents:
diff changeset
   454
       else if(schemaType == XMLGrammarDescription.XML_DTD) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   455
           ++freeDTDValidatorIndex;
7f561c08de6b Initial load
duke
parents:
diff changeset
   456
           if (dtdValidators.length == freeDTDValidatorIndex ){
7f561c08de6b Initial load
duke
parents:
diff changeset
   457
                // resize size of the validators
7f561c08de6b Initial load
duke
parents:
diff changeset
   458
                currentSize+=SIZE;
7f561c08de6b Initial load
duke
parents:
diff changeset
   459
                RevalidationHandler newarray[] =  new RevalidationHandler[currentSize];
7f561c08de6b Initial load
duke
parents:
diff changeset
   460
                System.arraycopy(dtdValidators, 0, newarray, 0, dtdValidators.length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   461
                dtdValidators = newarray;
7f561c08de6b Initial load
duke
parents:
diff changeset
   462
           }
7f561c08de6b Initial load
duke
parents:
diff changeset
   463
           dtdValidators[freeDTDValidatorIndex]=validator;
7f561c08de6b Initial load
duke
parents:
diff changeset
   464
       }
7f561c08de6b Initial load
duke
parents:
diff changeset
   465
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   466
7f561c08de6b Initial load
duke
parents:
diff changeset
   467
       /** NON-DOM:  increment document/doctype counter */
7f561c08de6b Initial load
duke
parents:
diff changeset
   468
       protected synchronized int assignDocumentNumber() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   469
            return ++docAndDoctypeCounter;
7f561c08de6b Initial load
duke
parents:
diff changeset
   470
       }
7f561c08de6b Initial load
duke
parents:
diff changeset
   471
       /** NON-DOM:  increment document/doctype counter */
7f561c08de6b Initial load
duke
parents:
diff changeset
   472
       protected synchronized int assignDocTypeNumber() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   473
            return ++docAndDoctypeCounter;
7f561c08de6b Initial load
duke
parents:
diff changeset
   474
       }
7f561c08de6b Initial load
duke
parents:
diff changeset
   475
7f561c08de6b Initial load
duke
parents:
diff changeset
   476
    /* DOM Level 3 LS CR - Experimental.
7f561c08de6b Initial load
duke
parents:
diff changeset
   477
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   478
     * Create a new empty output destination object where
7f561c08de6b Initial load
duke
parents:
diff changeset
   479
     * <code>LSOutput.characterStream</code>,
7f561c08de6b Initial load
duke
parents:
diff changeset
   480
     * <code>LSOutput.byteStream</code>, <code>LSOutput.systemId</code>,
7f561c08de6b Initial load
duke
parents:
diff changeset
   481
     * <code>LSOutput.encoding</code> are null.
7f561c08de6b Initial load
duke
parents:
diff changeset
   482
7f561c08de6b Initial load
duke
parents:
diff changeset
   483
     * @return  The newly created output object.
7f561c08de6b Initial load
duke
parents:
diff changeset
   484
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   485
       public LSOutput createLSOutput() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   486
           return new DOMOutputImpl();
7f561c08de6b Initial load
duke
parents:
diff changeset
   487
       }
7f561c08de6b Initial load
duke
parents:
diff changeset
   488
7f561c08de6b Initial load
duke
parents:
diff changeset
   489
} // class DOMImplementationImpl