jaxp/src/share/classes/com/sun/xml/internal/stream/dtd/DTDGrammarUtil.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
 * Portions Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 */
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 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
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
package com.sun.xml.internal.stream.dtd;
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
import com.sun.xml.internal.stream.dtd.nonvalidating.DTDGrammar;
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
import com.sun.xml.internal.stream.dtd.nonvalidating.XMLAttributeDecl;
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
import com.sun.xml.internal.stream.dtd.nonvalidating.XMLElementDecl;
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import com.sun.xml.internal.stream.dtd.nonvalidating.XMLSimpleType;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import com.sun.org.apache.xerces.internal.impl.Constants;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
import com.sun.org.apache.xerces.internal.util.SymbolTable;
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
import com.sun.org.apache.xerces.internal.util.XMLChar;
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
import com.sun.org.apache.xerces.internal.xni.Augmentations;
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
import com.sun.org.apache.xerces.internal.xni.QName;
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
import com.sun.org.apache.xerces.internal.xni.XMLLocator;
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
import com.sun.org.apache.xerces.internal.xni.XMLString;
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
import com.sun.org.apache.xerces.internal.xni.XNIException;
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
import javax.xml.XMLConstants;
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 /*
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
  * @author Eric Ye, IBM
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
  * @author Andy Clark, IBM
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
  * @author Jeffrey Rodriguez IBM
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
  * @author Neil Graham, IBM
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
  * @author Sunitha Reddy, Sun Microsystems
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
  */
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
public class DTDGrammarUtil {
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
    /** Property identifier: symbol table. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
    protected static final String SYMBOL_TABLE =
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
    Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
    protected static final String NAMESPACES =
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
    Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
    /** Compile to true to debug attributes. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
    private static final boolean DEBUG_ATTRIBUTES = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
    /** Compile to true to debug element children. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
    private static final boolean DEBUG_ELEMENT_CHILDREN = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
    protected DTDGrammar fDTDGrammar = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
    /** Namespaces. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
    protected boolean fNamespaces;
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
    /** Symbol table. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
    protected SymbolTable fSymbolTable = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
    /** Current element index. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
    private int fCurrentElementIndex = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
    /** Current content spec type. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
    private int fCurrentContentSpecType = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
    /** Content spec type stack. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
    private boolean[] fElementContentState = new boolean[8];
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
    /** Element depth. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
    private int fElementDepth = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
    /** True if inside of element content. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
    private boolean fInElementContent = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
    /** Temporary atribute declaration. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
    private XMLAttributeDecl fTempAttDecl = new XMLAttributeDecl();
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
    /** Temporary qualified name. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
    private QName fTempQName = new QName();
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
    /** Temporary string buffers. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
    private StringBuffer fBuffer = new StringBuffer();
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
    private NamespaceContext fNamespaceContext = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
    /** Default constructor. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
    public DTDGrammarUtil(SymbolTable symbolTable) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
        fSymbolTable = symbolTable;
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
    public DTDGrammarUtil(DTDGrammar grammar, SymbolTable symbolTable) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
        fDTDGrammar = grammar;
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
        fSymbolTable = symbolTable;
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
    public DTDGrammarUtil(DTDGrammar grammar, SymbolTable symbolTable,
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
            NamespaceContext namespaceContext) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
        fDTDGrammar = grammar;
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
        fSymbolTable = symbolTable;
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
        fNamespaceContext = namespaceContext;
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
    /*
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
     * Resets the component. The component can query the component manager
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
     * about any features and properties that affect the operation of the
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
     * component.
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
     * @param componentManager The component manager.
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
     * @throws SAXException Thrown by component on finitialization error.
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
     *                      For example, if a feature or property is
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
     *                      required for the operation of the component, the
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
     *                      component manager may throw a
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
     *                      SAXNotRecognizedException or a
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
     *                      SAXNotSupportedException.
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
    public void reset(XMLComponentManager componentManager)
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
    throws XMLConfigurationException {
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
        fDTDGrammar = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
        fInElementContent = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
        fCurrentElementIndex = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
        fCurrentContentSpecType = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
        try {
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
            fNamespaces = componentManager.getFeature(NAMESPACES);
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
        } catch (XMLConfigurationException e) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
            fNamespaces = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
        fSymbolTable = (SymbolTable) componentManager.getProperty(
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
                Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY);
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
        fElementDepth = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
     * The start of an element.
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
     * @param element    The name of the element.
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
     * @param attributes The element attributes.
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
     * @param augs   Additional information that may include infoset augmentations
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
     * @throws XNIException Thrown by handler to signal an error.
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
    public void startElement(QName element, XMLAttributes attributes)  throws XNIException {
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
        handleStartElement(element, attributes);
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
     * The end of an element.
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
     * @param element The name of the element.
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
     * @param augs   Additional information that may include infoset augmentations
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
     * @throws XNIException Thrown by handler to signal an error.
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
    public void endElement(QName element) throws XNIException {
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
        handleEndElement(element);
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
     * The start of a CDATA section.
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
     * @param augs   Additional information that may include infoset augmentations
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
     * @throws XNIException Thrown by handler to signal an error.
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
    public void startCDATA(Augmentations augs) throws XNIException {
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
     * The end of a CDATA section.
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
     * @param augs   Additional information that may include infoset augmentations
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
     * @throws XNIException Thrown by handler to signal an error.
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
    public void endCDATA(Augmentations augs) throws XNIException {
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
    /** Add default attributes and validate. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
    public void addDTDDefaultAttrs(QName elementName, XMLAttributes attributes)
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
    throws XNIException {
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
        int elementIndex;
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
        elementIndex = fDTDGrammar.getElementDeclIndex(elementName);
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
        // is there anything to do?
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
        if (elementIndex == -1 || fDTDGrammar == null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
            return;
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
        //
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
        // Check after all specified attrs are scanned
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
        // (1) report error for REQUIRED attrs that are missing (V_TAGc)
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
        // (2) add default attrs (FIXED and NOT_FIXED)
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
        //
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
        int attlistIndex = fDTDGrammar.getFirstAttributeDeclIndex(elementIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
        while (attlistIndex != -1) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
            fDTDGrammar.getAttributeDecl(attlistIndex, fTempAttDecl);
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
            if (DEBUG_ATTRIBUTES) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
                if (fTempAttDecl != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
                    XMLElementDecl elementDecl = new XMLElementDecl();
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
                    fDTDGrammar.getElementDecl(elementIndex, elementDecl);
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
                    System.out.println("element: " + (elementDecl.name.localpart));
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
                    System.out.println("attlistIndex " + attlistIndex + "\n" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
                    "attName : '" + (fTempAttDecl.name.localpart) + "'\n"
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
                    + "attType : " + fTempAttDecl.simpleType.type + "\n"
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
                    + "attDefaultType : " + fTempAttDecl.simpleType.defaultType + "\n"
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
                    + "attDefaultValue : '" + fTempAttDecl.simpleType.defaultValue + "'\n"
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
                    + attributes.getLength() + "\n"
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
                    );
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
            String attPrefix = fTempAttDecl.name.prefix;
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
            String attLocalpart = fTempAttDecl.name.localpart;
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
            String attRawName = fTempAttDecl.name.rawname;
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
            String attType = getAttributeTypeName(fTempAttDecl);
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
            int attDefaultType = fTempAttDecl.simpleType.defaultType;
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
            String attValue = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
            if (fTempAttDecl.simpleType.defaultValue != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
                attValue = fTempAttDecl.simpleType.defaultValue;
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
            boolean specified = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
            boolean required = attDefaultType == XMLSimpleType.DEFAULT_TYPE_REQUIRED;
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
            boolean cdata = attType == XMLSymbols.fCDATASymbol;
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
            if (!cdata || required || attValue != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
                //check whether attribute is a namespace declaration
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
                if (fNamespaceContext != null && attRawName.startsWith(XMLConstants.XMLNS_ATTRIBUTE)) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
                    String prefix = "";
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
                    int pos = attRawName.indexOf(':');
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
                    if (pos != -1) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
                        prefix = attRawName.substring(0, pos);
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
                    } else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
                        prefix = attRawName;
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
                    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   258
                    prefix = fSymbolTable.addSymbol(prefix);
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
                    if (!((com.sun.org.apache.xerces.internal.util.
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
                            NamespaceSupport) fNamespaceContext).
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
                            containsPrefixInCurrentContext(prefix)) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
                        fNamespaceContext.declarePrefix(prefix, attValue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
                    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
                    specified = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
                } else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   266
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
                    int attrCount = attributes.getLength();
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
                    for (int i = 0; i < attrCount; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   269
                        if (attributes.getQName(i) == attRawName) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   270
                            specified = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
                            break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   272
                        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   273
                    }
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
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   278
7f561c08de6b Initial load
duke
parents:
diff changeset
   279
            if (!specified) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   280
                if (attValue != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   281
                    if (fNamespaces) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   282
                        int index = attRawName.indexOf(':');
7f561c08de6b Initial load
duke
parents:
diff changeset
   283
                        if (index != -1) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   284
                            attPrefix = attRawName.substring(0, index);
7f561c08de6b Initial load
duke
parents:
diff changeset
   285
                            attPrefix = fSymbolTable.addSymbol(attPrefix);
7f561c08de6b Initial load
duke
parents:
diff changeset
   286
                            attLocalpart = attRawName.substring(index + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   287
                            attLocalpart = fSymbolTable.addSymbol(attLocalpart);
7f561c08de6b Initial load
duke
parents:
diff changeset
   288
                        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   289
                    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   290
                    fTempQName.setValues(attPrefix, attLocalpart, attRawName,
7f561c08de6b Initial load
duke
parents:
diff changeset
   291
                            fTempAttDecl.name.uri);
7f561c08de6b Initial load
duke
parents:
diff changeset
   292
                    int newAttr = attributes.addAttribute(fTempQName, attType,
7f561c08de6b Initial load
duke
parents:
diff changeset
   293
                            attValue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   294
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   295
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   296
            attlistIndex = fDTDGrammar.getNextAttributeDeclIndex(attlistIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   297
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   298
7f561c08de6b Initial load
duke
parents:
diff changeset
   299
        // now iterate through the expanded attributes for
7f561c08de6b Initial load
duke
parents:
diff changeset
   300
        // 1. if every attribute seen is declared in the DTD
7f561c08de6b Initial load
duke
parents:
diff changeset
   301
        // 2. check if the VC: default_fixed holds
7f561c08de6b Initial load
duke
parents:
diff changeset
   302
        // 3. validate every attribute.
7f561c08de6b Initial load
duke
parents:
diff changeset
   303
        int attrCount = attributes.getLength();
7f561c08de6b Initial load
duke
parents:
diff changeset
   304
        for (int i = 0; i < attrCount; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   305
            String attrRawName = attributes.getQName(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
   306
            boolean declared = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   307
            int position =
7f561c08de6b Initial load
duke
parents:
diff changeset
   308
            fDTDGrammar.getFirstAttributeDeclIndex(elementIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   309
            while (position != -1) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   310
                fDTDGrammar.getAttributeDecl(position, fTempAttDecl);
7f561c08de6b Initial load
duke
parents:
diff changeset
   311
                if (fTempAttDecl.name.rawname == attrRawName) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   312
                    // found the match att decl,
7f561c08de6b Initial load
duke
parents:
diff changeset
   313
                    declared = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   314
                    break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   315
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   316
                position = fDTDGrammar.getNextAttributeDeclIndex(position);
7f561c08de6b Initial load
duke
parents:
diff changeset
   317
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   318
            if (!declared) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   319
                continue;
7f561c08de6b Initial load
duke
parents:
diff changeset
   320
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   321
7f561c08de6b Initial load
duke
parents:
diff changeset
   322
            String type = getAttributeTypeName(fTempAttDecl);
7f561c08de6b Initial load
duke
parents:
diff changeset
   323
            attributes.setType(i, type);
7f561c08de6b Initial load
duke
parents:
diff changeset
   324
7f561c08de6b Initial load
duke
parents:
diff changeset
   325
            boolean changedByNormalization = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   326
            if (attributes.isSpecified(i) && type != XMLSymbols.fCDATASymbol) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   327
                changedByNormalization = normalizeAttrValue(attributes, i);
7f561c08de6b Initial load
duke
parents:
diff changeset
   328
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   329
        } // for all attributes
7f561c08de6b Initial load
duke
parents:
diff changeset
   330
7f561c08de6b Initial load
duke
parents:
diff changeset
   331
    } // addDTDDefaultAttrsAndValidate(int,XMLAttrList)
7f561c08de6b Initial load
duke
parents:
diff changeset
   332
7f561c08de6b Initial load
duke
parents:
diff changeset
   333
7f561c08de6b Initial load
duke
parents:
diff changeset
   334
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   335
     * Normalize the attribute value of a non CDATA attributes collapsing
7f561c08de6b Initial load
duke
parents:
diff changeset
   336
     * sequences of space characters (x20)
7f561c08de6b Initial load
duke
parents:
diff changeset
   337
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   338
     * @param attributes The list of attributes
7f561c08de6b Initial load
duke
parents:
diff changeset
   339
     * @param index The index of the attribute to normalize
7f561c08de6b Initial load
duke
parents:
diff changeset
   340
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   341
    private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   342
        // vars
7f561c08de6b Initial load
duke
parents:
diff changeset
   343
        boolean leadingSpace = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   344
        boolean spaceStart = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   345
        boolean readingNonSpace = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   346
        int count = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
   347
        int eaten = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
   348
        String attrValue = attributes.getValue(index);
7f561c08de6b Initial load
duke
parents:
diff changeset
   349
        char[] attValue = new char[attrValue.length()];
7f561c08de6b Initial load
duke
parents:
diff changeset
   350
7f561c08de6b Initial load
duke
parents:
diff changeset
   351
        fBuffer.setLength(0);
7f561c08de6b Initial load
duke
parents:
diff changeset
   352
        attrValue.getChars(0, attrValue.length(), attValue, 0);
7f561c08de6b Initial load
duke
parents:
diff changeset
   353
        for (int i = 0; i < attValue.length; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   354
7f561c08de6b Initial load
duke
parents:
diff changeset
   355
            if (attValue[i] == ' ') {
7f561c08de6b Initial load
duke
parents:
diff changeset
   356
7f561c08de6b Initial load
duke
parents:
diff changeset
   357
                // now the tricky part
7f561c08de6b Initial load
duke
parents:
diff changeset
   358
                if (readingNonSpace) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   359
                    spaceStart = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   360
                    readingNonSpace = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   361
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   362
7f561c08de6b Initial load
duke
parents:
diff changeset
   363
                if (spaceStart && !leadingSpace) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   364
                    spaceStart = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   365
                    fBuffer.append(attValue[i]);
7f561c08de6b Initial load
duke
parents:
diff changeset
   366
                    count++;
7f561c08de6b Initial load
duke
parents:
diff changeset
   367
                } else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   368
                    if (leadingSpace || !spaceStart) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   369
                        eaten++;
7f561c08de6b Initial load
duke
parents:
diff changeset
   370
                    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   371
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   372
7f561c08de6b Initial load
duke
parents:
diff changeset
   373
            } else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   374
                readingNonSpace = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   375
                spaceStart = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   376
                leadingSpace = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   377
                fBuffer.append(attValue[i]);
7f561c08de6b Initial load
duke
parents:
diff changeset
   378
                count++;
7f561c08de6b Initial load
duke
parents:
diff changeset
   379
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   380
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   381
7f561c08de6b Initial load
duke
parents:
diff changeset
   382
        // check if the last appended character is a space.
7f561c08de6b Initial load
duke
parents:
diff changeset
   383
        if (count > 0 && fBuffer.charAt(count - 1) == ' ') {
7f561c08de6b Initial load
duke
parents:
diff changeset
   384
            fBuffer.setLength(count - 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   385
7f561c08de6b Initial load
duke
parents:
diff changeset
   386
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   387
        String newValue = fBuffer.toString();
7f561c08de6b Initial load
duke
parents:
diff changeset
   388
        attributes.setValue(index, newValue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   389
        return !attrValue.equals(newValue);
7f561c08de6b Initial load
duke
parents:
diff changeset
   390
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   391
7f561c08de6b Initial load
duke
parents:
diff changeset
   392
7f561c08de6b Initial load
duke
parents:
diff changeset
   393
7f561c08de6b Initial load
duke
parents:
diff changeset
   394
    /** convert attribute type from ints to strings */
7f561c08de6b Initial load
duke
parents:
diff changeset
   395
    private String getAttributeTypeName(XMLAttributeDecl attrDecl) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   396
7f561c08de6b Initial load
duke
parents:
diff changeset
   397
        switch (attrDecl.simpleType.type) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   398
            case XMLSimpleType.TYPE_ENTITY: {
7f561c08de6b Initial load
duke
parents:
diff changeset
   399
                return attrDecl.simpleType.list ? XMLSymbols.fENTITIESSymbol :
7f561c08de6b Initial load
duke
parents:
diff changeset
   400
                    XMLSymbols.fENTITYSymbol;
7f561c08de6b Initial load
duke
parents:
diff changeset
   401
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   402
            case XMLSimpleType.TYPE_ENUMERATION: {
7f561c08de6b Initial load
duke
parents:
diff changeset
   403
                StringBuffer buffer = new StringBuffer();
7f561c08de6b Initial load
duke
parents:
diff changeset
   404
                buffer.append('(');
7f561c08de6b Initial load
duke
parents:
diff changeset
   405
                for (int i = 0; i < attrDecl.simpleType.enumeration.length; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   406
                    if (i > 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   407
                        buffer.append("|");
7f561c08de6b Initial load
duke
parents:
diff changeset
   408
                    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   409
                    buffer.append(attrDecl.simpleType.enumeration[i]);
7f561c08de6b Initial load
duke
parents:
diff changeset
   410
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   411
                buffer.append(')');
7f561c08de6b Initial load
duke
parents:
diff changeset
   412
                return fSymbolTable.addSymbol(buffer.toString());
7f561c08de6b Initial load
duke
parents:
diff changeset
   413
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   414
            case XMLSimpleType.TYPE_ID: {
7f561c08de6b Initial load
duke
parents:
diff changeset
   415
                return XMLSymbols.fIDSymbol;
7f561c08de6b Initial load
duke
parents:
diff changeset
   416
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   417
            case XMLSimpleType.TYPE_IDREF: {
7f561c08de6b Initial load
duke
parents:
diff changeset
   418
                return attrDecl.simpleType.list ? XMLSymbols.fIDREFSSymbol :
7f561c08de6b Initial load
duke
parents:
diff changeset
   419
                    XMLSymbols.fIDREFSymbol;
7f561c08de6b Initial load
duke
parents:
diff changeset
   420
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   421
            case XMLSimpleType.TYPE_NMTOKEN: {
7f561c08de6b Initial load
duke
parents:
diff changeset
   422
                return attrDecl.simpleType.list ? XMLSymbols.fNMTOKENSSymbol :
7f561c08de6b Initial load
duke
parents:
diff changeset
   423
                    XMLSymbols.fNMTOKENSymbol;
7f561c08de6b Initial load
duke
parents:
diff changeset
   424
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   425
            case XMLSimpleType.TYPE_NOTATION: {
7f561c08de6b Initial load
duke
parents:
diff changeset
   426
                return XMLSymbols.fNOTATIONSymbol;
7f561c08de6b Initial load
duke
parents:
diff changeset
   427
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   428
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   429
        return XMLSymbols.fCDATASymbol;
7f561c08de6b Initial load
duke
parents:
diff changeset
   430
7f561c08de6b Initial load
duke
parents:
diff changeset
   431
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   432
7f561c08de6b Initial load
duke
parents:
diff changeset
   433
7f561c08de6b Initial load
duke
parents:
diff changeset
   434
    /** ensure element stack capacity */
7f561c08de6b Initial load
duke
parents:
diff changeset
   435
    private void ensureStackCapacity(int newElementDepth) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   436
        if (newElementDepth == fElementContentState.length) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   437
            boolean[] newStack = new boolean[newElementDepth * 2];
7f561c08de6b Initial load
duke
parents:
diff changeset
   438
            System.arraycopy(this.fElementContentState, 0, newStack, 0,
7f561c08de6b Initial load
duke
parents:
diff changeset
   439
                    newElementDepth);
7f561c08de6b Initial load
duke
parents:
diff changeset
   440
            fElementContentState = newStack;
7f561c08de6b Initial load
duke
parents:
diff changeset
   441
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   442
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   443
7f561c08de6b Initial load
duke
parents:
diff changeset
   444
7f561c08de6b Initial load
duke
parents:
diff changeset
   445
7f561c08de6b Initial load
duke
parents:
diff changeset
   446
    /** Handle element
7f561c08de6b Initial load
duke
parents:
diff changeset
   447
     * @return true if validator is removed from the pipeline
7f561c08de6b Initial load
duke
parents:
diff changeset
   448
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   449
    protected void handleStartElement(QName element, XMLAttributes attributes) throws XNIException {
7f561c08de6b Initial load
duke
parents:
diff changeset
   450
7f561c08de6b Initial load
duke
parents:
diff changeset
   451
        if (fDTDGrammar == null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   452
            fCurrentElementIndex = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   453
            fCurrentContentSpecType = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   454
            fInElementContent = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   455
            return;
7f561c08de6b Initial load
duke
parents:
diff changeset
   456
        } else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   457
            fCurrentElementIndex = fDTDGrammar.getElementDeclIndex(element);
7f561c08de6b Initial load
duke
parents:
diff changeset
   458
            fCurrentContentSpecType = fDTDGrammar.getContentSpecType(
7f561c08de6b Initial load
duke
parents:
diff changeset
   459
                    fCurrentElementIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   460
            //handleDTDDefaultAttrs(element,attributes);
7f561c08de6b Initial load
duke
parents:
diff changeset
   461
            addDTDDefaultAttrs(element, attributes);
7f561c08de6b Initial load
duke
parents:
diff changeset
   462
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   463
7f561c08de6b Initial load
duke
parents:
diff changeset
   464
        fInElementContent = fCurrentContentSpecType == XMLElementDecl.TYPE_CHILDREN;
7f561c08de6b Initial load
duke
parents:
diff changeset
   465
        fElementDepth++;
7f561c08de6b Initial load
duke
parents:
diff changeset
   466
        ensureStackCapacity(fElementDepth);
7f561c08de6b Initial load
duke
parents:
diff changeset
   467
        fElementContentState[fElementDepth] = fInElementContent;
7f561c08de6b Initial load
duke
parents:
diff changeset
   468
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   469
7f561c08de6b Initial load
duke
parents:
diff changeset
   470
7f561c08de6b Initial load
duke
parents:
diff changeset
   471
    /** Handle end element. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   472
    protected void handleEndElement(QName element) throws XNIException {
7f561c08de6b Initial load
duke
parents:
diff changeset
   473
        if (fDTDGrammar == null) return;
7f561c08de6b Initial load
duke
parents:
diff changeset
   474
        fElementDepth--;
7f561c08de6b Initial load
duke
parents:
diff changeset
   475
        if (fElementDepth < -1) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   476
            throw new RuntimeException("FWK008 Element stack underflow");
7f561c08de6b Initial load
duke
parents:
diff changeset
   477
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   478
        if (fElementDepth < 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   479
            fCurrentElementIndex = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   480
            fCurrentContentSpecType = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   481
            fInElementContent = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   482
            return;
7f561c08de6b Initial load
duke
parents:
diff changeset
   483
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   484
        fInElementContent =  fElementContentState[fElementDepth];
7f561c08de6b Initial load
duke
parents:
diff changeset
   485
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   486
7f561c08de6b Initial load
duke
parents:
diff changeset
   487
    public boolean isInElementContent() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   488
        return fInElementContent;
7f561c08de6b Initial load
duke
parents:
diff changeset
   489
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   490
7f561c08de6b Initial load
duke
parents:
diff changeset
   491
    public boolean isIgnorableWhiteSpace(XMLString text) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   492
        if (isInElementContent()) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   493
            for (int i = text.offset; i < text.offset + text.length; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   494
                if (!XMLChar.isSpace(text.ch[i])) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   495
                    return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   496
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   497
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   498
            return true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   499
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   500
        return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   501
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   502
}