src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM.java
author joehw
Wed, 18 Oct 2017 13:25:49 -0700
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
child 48409 5ab69533994b
permissions -rw-r--r--
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked Reviewed-by: lancea, rriggs, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
     2
 * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
     3
 * @LastModified: Oct 2017
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one or more
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
     7
 * contributor license agreements.  See the NOTICE file distributed with
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
     8
 * this work for additional information regarding copyright ownership.
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
     9
 * The ASF licenses this file to You under the Apache License, Version 2.0
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    10
 * (the "License"); you may not use this file except in compliance with
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    11
 * the License.  You may obtain a copy of the License at
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 *     http://www.apache.org/licenses/LICENSE-2.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
 */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    21
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
package com.sun.org.apache.xml.internal.dtm.ref.sax2dtm;
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    24
import com.sun.org.apache.xml.internal.dtm.DTM;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    25
import com.sun.org.apache.xml.internal.dtm.DTMManager;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    26
import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    27
import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBaseIterators;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    28
import com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    29
import com.sun.org.apache.xml.internal.dtm.ref.DTMStringPool;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    30
import com.sun.org.apache.xml.internal.dtm.ref.DTMTreeWalker;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    31
import com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    32
import com.sun.org.apache.xml.internal.dtm.ref.NodeLocator;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    33
import com.sun.org.apache.xml.internal.res.XMLErrorResources;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    34
import com.sun.org.apache.xml.internal.res.XMLMessages;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
import com.sun.org.apache.xml.internal.utils.FastStringBuffer;
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
import com.sun.org.apache.xml.internal.utils.IntStack;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    37
import com.sun.org.apache.xml.internal.utils.IntVector;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    38
import com.sun.org.apache.xml.internal.utils.StringVector;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
import com.sun.org.apache.xml.internal.utils.SuballocatedIntVector;
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
import com.sun.org.apache.xml.internal.utils.WrappedRuntimeException;
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
import com.sun.org.apache.xml.internal.utils.XMLString;
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    44
import java.util.ArrayList;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    45
import java.util.HashMap;
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    46
import java.util.List;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    47
import java.util.Map;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    48
import java.util.Vector;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    49
import javax.xml.transform.Source;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
    50
import javax.xml.transform.SourceLocator;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    51
import org.xml.sax.Attributes;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    52
import org.xml.sax.ContentHandler;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    53
import org.xml.sax.DTDHandler;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    54
import org.xml.sax.EntityResolver;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    55
import org.xml.sax.ErrorHandler;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    56
import org.xml.sax.InputSource;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    57
import org.xml.sax.Locator;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    58
import org.xml.sax.SAXException;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    59
import org.xml.sax.SAXParseException;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    60
import org.xml.sax.ext.DeclHandler;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
    61
import org.xml.sax.ext.LexicalHandler;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
 * This class implements a DTM that tends to be optimized more for speed than
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
 * for compactness, that is constructed via SAX2 ContentHandler events.
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
public class SAX2DTM extends DTMDefaultBaseIterators
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
        implements EntityResolver, DTDHandler, ContentHandler, ErrorHandler,
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
                   DeclHandler, LexicalHandler
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
{
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
  /** Set true to monitor SAX events and similar diagnostic info. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
  private static final boolean DEBUG = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
   * If we're building the model incrementally on demand, we need to
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
   * be able to tell the source when to send us more data.
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
   * Note that if this has not been set, and you attempt to read ahead
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
   * of the current build point, we'll probably throw a null-pointer
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
   * exception. We could try to wait-and-retry instead, as a very poor
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
   * fallback, but that has all the known problems with multithreading
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
   * on multiprocessors and we Don't Want to Go There.
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
   * @see setIncrementalSAXSource
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
  private IncrementalSAXSource m_incrementalSAXSource = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
   * All the character content, including attribute values, are stored in
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
   * this buffer.
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
   * %REVIEW% Should this have an option of being shared across DTMs?
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
   * Sequentially only; not threadsafe... Currently, I think not.
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
   * %REVIEW% Initial size was pushed way down to reduce weight of RTFs.
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
   * pending reduction in number of RTF DTMs. Now that we're sharing a DTM
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
   * between RTFs, and tail-pruning... consider going back to the larger/faster.
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
   * Made protected rather than private so SAX2RTFDTM can access it.
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
  protected FastStringBuffer m_chars;
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
  /** This vector holds offset and length data.
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
  protected SuballocatedIntVector m_data;
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
  /** The parent stack, needed only for construction.
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
   * Made protected rather than private so SAX2RTFDTM can access it.
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
  transient protected IntStack m_parents;
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
  /** The current previous node, needed only for construction time.
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
   * Made protected rather than private so SAX2RTFDTM can access it.
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
  transient protected int m_previous = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
  /** Namespace support, only relevent at construction time.
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
   * Made protected rather than private so SAX2RTFDTM can access it.
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   120
  transient protected Vector<String> m_prefixMappings = new Vector<>();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
  /** Namespace support, only relevent at construction time.
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
   * Made protected rather than private so SAX2RTFDTM can access it.
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
  transient protected IntStack m_contextIndexes;
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
  /** Type of next characters() event within text block in prgress. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
  transient protected int m_textType = DTM.TEXT_NODE;
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
   * Type of coalesced text block. See logic in the characters()
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
   * method.
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
  transient protected int m_coalescedTextType = DTM.TEXT_NODE;
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
  /** The SAX Document locator */
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
  transient protected Locator m_locator = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
  /** The SAX Document system-id */
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
  transient private String m_systemId = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
  /** We are inside the DTD.  This is used for ignoring comments.  */
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
  transient protected boolean m_insideDTD = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
  /** Tree Walker for dispatchToEvents. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
  protected DTMTreeWalker m_walker = new DTMTreeWalker();
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
  /** pool of string values that come as strings. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
  protected DTMStringPool m_valuesOrPrefixes;
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
  /** End document has been reached.
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
   * Made protected rather than private so SAX2RTFDTM can access it.
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
  protected boolean m_endDocumentOccured = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
  /** Data or qualified name values, one array element for each node. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
  protected SuballocatedIntVector m_dataOrQName;
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
   * This table holds the ID string to node associations, for
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
   * XML IDs.
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
   */
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
   163
  protected Map<String, Integer> m_idAttributes = new HashMap<>();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
   * fixed dom-style names.
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
  private static final String[] m_fixednames = { null,
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
                    null,  // nothing, Element
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
                    null, "#text",  // Attr, Text
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
                    "#cdata_section", null,  // CDATA, EntityReference
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
                    null, null,  // Entity, PI
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
                    "#comment", "#document",  // Comment, Document
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
                    null, "#document-fragment",  // Doctype, DocumentFragment
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
                    null };  // Notation
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
   * Vector of entities.  Each record is composed of four Strings:
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
   *  publicId, systemID, notationName, and name.
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
   */
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   181
  private List<String> m_entities = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
  /** m_entities public ID offset. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
  private static final int ENTITY_FIELD_PUBLICID = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
  /** m_entities system ID offset. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
  private static final int ENTITY_FIELD_SYSTEMID = 1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
  /** m_entities notation name offset. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
  private static final int ENTITY_FIELD_NOTATIONNAME = 2;
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
  /** m_entities name offset. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
  private static final int ENTITY_FIELD_NAME = 3;
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
  /** Number of entries per record for m_entities. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
  private static final int ENTITY_FIELDS_PER = 4;
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
   * The starting offset within m_chars for the text or
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
   * CDATA_SECTION node currently being acumulated,
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
   * or -1 if there is no text node in progress
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
  protected int m_textPendingStart = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
   * Describes whether information about document source location
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
   * should be maintained or not.
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
   * Made protected for access by SAX2RTFDTM.
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
  protected boolean m_useSourceLocationProperty = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   213
  /** Made protected for access by SAX2RTFDTM.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
  protected StringVector m_sourceSystemId;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   216
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   217
  /** Made protected for access by SAX2RTFDTM.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
  protected IntVector m_sourceLine;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   220
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   221
  /** Made protected for access by SAX2RTFDTM.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
  protected IntVector m_sourceColumn;
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
   * Construct a SAX2DTM object using the default block size.
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
   * @param mgr The DTMManager who owns this DTM.
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
   * @param source the JAXP 1.1 Source object for this DTM.
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
   * @param dtmIdentity The DTM identity ID for this DTM.
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
   * @param whiteSpaceFilter The white space filter for this DTM, which may
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
   *                         be null.
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
   * @param xstringfactory XMLString factory for creating character content.
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
   * @param doIndexing true if the caller considers it worth it to use
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
   *                   indexing schemes.
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
  public SAX2DTM(DTMManager mgr, Source source, int dtmIdentity,
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
                 DTMWSFilter whiteSpaceFilter,
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
                 XMLStringFactory xstringfactory,
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
                 boolean doIndexing)
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
    this(mgr, source, dtmIdentity, whiteSpaceFilter,
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
          xstringfactory, doIndexing, DEFAULT_BLOCKSIZE, true, false);
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
   * Construct a SAX2DTM object ready to be constructed from SAX2
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
   * ContentHandler events.
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
   * @param mgr The DTMManager who owns this DTM.
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
   * @param source the JAXP 1.1 Source object for this DTM.
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
   * @param dtmIdentity The DTM identity ID for this DTM.
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
   * @param whiteSpaceFilter The white space filter for this DTM, which may
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
   *                         be null.
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
   * @param xstringfactory XMLString factory for creating character content.
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
   * @param doIndexing true if the caller considers it worth it to use
7f561c08de6b Initial load
duke
parents:
diff changeset
   258
   *                   indexing schemes.
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
   * @param blocksize The block size of the DTM.
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
   * @param usePrevsib true if we want to build the previous sibling node array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
   * @param newNameTable true if we want to use a new ExpandedNameTable for this DTM.
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
  public SAX2DTM(DTMManager mgr, Source source, int dtmIdentity,
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
                 DTMWSFilter whiteSpaceFilter,
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
                 XMLStringFactory xstringfactory,
7f561c08de6b Initial load
duke
parents:
diff changeset
   266
                 boolean doIndexing,
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
                 int blocksize,
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
                 boolean usePrevsib,
7f561c08de6b Initial load
duke
parents:
diff changeset
   269
                 boolean newNameTable)
7f561c08de6b Initial load
duke
parents:
diff changeset
   270
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
    super(mgr, source, dtmIdentity, whiteSpaceFilter,
7f561c08de6b Initial load
duke
parents:
diff changeset
   272
          xstringfactory, doIndexing, blocksize, usePrevsib, newNameTable);
7f561c08de6b Initial load
duke
parents:
diff changeset
   273
7f561c08de6b Initial load
duke
parents:
diff changeset
   274
    // %OPT% Use smaller sizes for all internal storage units when
7f561c08de6b Initial load
duke
parents:
diff changeset
   275
    // the blocksize is small. This reduces the cost of creating an RTF.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   276
    if (blocksize <= 64) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   277
      m_data = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS_SMALL);
7f561c08de6b Initial load
duke
parents:
diff changeset
   278
      m_dataOrQName = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS_SMALL);
7f561c08de6b Initial load
duke
parents:
diff changeset
   279
      m_valuesOrPrefixes = new DTMStringPool(16);
7f561c08de6b Initial load
duke
parents:
diff changeset
   280
      m_chars = new FastStringBuffer(7, 10);
7f561c08de6b Initial load
duke
parents:
diff changeset
   281
      m_contextIndexes = new IntStack(4);
7f561c08de6b Initial load
duke
parents:
diff changeset
   282
      m_parents = new IntStack(4);
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   283
    } else {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   284
      m_data = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS);
7f561c08de6b Initial load
duke
parents:
diff changeset
   285
      m_dataOrQName = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS);
7f561c08de6b Initial load
duke
parents:
diff changeset
   286
      m_valuesOrPrefixes = new DTMStringPool();
7f561c08de6b Initial load
duke
parents:
diff changeset
   287
      m_chars = new FastStringBuffer(10, 13);
7f561c08de6b Initial load
duke
parents:
diff changeset
   288
      m_contextIndexes = new IntStack();
7f561c08de6b Initial load
duke
parents:
diff changeset
   289
      m_parents = new IntStack();
7f561c08de6b Initial load
duke
parents:
diff changeset
   290
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   291
7f561c08de6b Initial load
duke
parents:
diff changeset
   292
    // %REVIEW%  Initial size pushed way down to reduce weight of RTFs
7f561c08de6b Initial load
duke
parents:
diff changeset
   293
    // (I'm not entirely sure 0 would work, so I'm playing it safe for now.)
7f561c08de6b Initial load
duke
parents:
diff changeset
   294
    //m_data = new SuballocatedIntVector(doIndexing ? (1024*2) : 512, 1024);
7f561c08de6b Initial load
duke
parents:
diff changeset
   295
    //m_data = new SuballocatedIntVector(blocksize);
7f561c08de6b Initial load
duke
parents:
diff changeset
   296
7f561c08de6b Initial load
duke
parents:
diff changeset
   297
    m_data.addElement(0);   // Need placeholder in case index into here must be <0.
7f561c08de6b Initial load
duke
parents:
diff changeset
   298
7f561c08de6b Initial load
duke
parents:
diff changeset
   299
    //m_dataOrQName = new SuballocatedIntVector(blocksize);
7f561c08de6b Initial load
duke
parents:
diff changeset
   300
7f561c08de6b Initial load
duke
parents:
diff changeset
   301
    // m_useSourceLocationProperty=com.sun.org.apache.xalan.internal.processor.TransformerFactoryImpl.m_source_location;
7f561c08de6b Initial load
duke
parents:
diff changeset
   302
    m_useSourceLocationProperty = mgr.getSource_location();
7f561c08de6b Initial load
duke
parents:
diff changeset
   303
    m_sourceSystemId = (m_useSourceLocationProperty) ? new StringVector() : null;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   304
    m_sourceLine = (m_useSourceLocationProperty) ?  new IntVector() : null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   305
    m_sourceColumn = (m_useSourceLocationProperty) ?  new IntVector() : null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   306
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   307
7f561c08de6b Initial load
duke
parents:
diff changeset
   308
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   309
   * Set whether information about document source location
7f561c08de6b Initial load
duke
parents:
diff changeset
   310
   * should be maintained or not.
7f561c08de6b Initial load
duke
parents:
diff changeset
   311
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   312
  public void setUseSourceLocation(boolean useSourceLocation) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   313
    m_useSourceLocationProperty = useSourceLocation;
7f561c08de6b Initial load
duke
parents:
diff changeset
   314
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   315
7f561c08de6b Initial load
duke
parents:
diff changeset
   316
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   317
   * Get the data or qualified name for the given node identity.
7f561c08de6b Initial load
duke
parents:
diff changeset
   318
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   319
   * @param identity The node identity.
7f561c08de6b Initial load
duke
parents:
diff changeset
   320
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   321
   * @return The data or qualified name, or DTM.NULL.
7f561c08de6b Initial load
duke
parents:
diff changeset
   322
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   323
  protected int _dataOrQName(int identity) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   324
    if (identity < m_size)
7f561c08de6b Initial load
duke
parents:
diff changeset
   325
      return m_dataOrQName.elementAt(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
   326
7f561c08de6b Initial load
duke
parents:
diff changeset
   327
    // Check to see if the information requested has been processed, and,
7f561c08de6b Initial load
duke
parents:
diff changeset
   328
    // if not, advance the iterator until we the information has been
7f561c08de6b Initial load
duke
parents:
diff changeset
   329
    // processed.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   330
    while (true) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   331
      boolean isMore = nextNode();
7f561c08de6b Initial load
duke
parents:
diff changeset
   332
7f561c08de6b Initial load
duke
parents:
diff changeset
   333
      if (!isMore)
7f561c08de6b Initial load
duke
parents:
diff changeset
   334
        return NULL;
7f561c08de6b Initial load
duke
parents:
diff changeset
   335
      else if (identity < m_size)
7f561c08de6b Initial load
duke
parents:
diff changeset
   336
        return m_dataOrQName.elementAt(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
   337
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   338
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   339
7f561c08de6b Initial load
duke
parents:
diff changeset
   340
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   341
   * Ask the CoRoutine parser to doTerminate and clear the reference.
7f561c08de6b Initial load
duke
parents:
diff changeset
   342
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   343
  public void clearCoRoutine() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   344
    clearCoRoutine(true);
7f561c08de6b Initial load
duke
parents:
diff changeset
   345
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   346
7f561c08de6b Initial load
duke
parents:
diff changeset
   347
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   348
   * Ask the CoRoutine parser to doTerminate and clear the reference. If
7f561c08de6b Initial load
duke
parents:
diff changeset
   349
   * the CoRoutine parser has already been cleared, this will have no effect.
7f561c08de6b Initial load
duke
parents:
diff changeset
   350
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   351
   * @param callDoTerminate true of doTerminate should be called on the
7f561c08de6b Initial load
duke
parents:
diff changeset
   352
   * coRoutine parser.
7f561c08de6b Initial load
duke
parents:
diff changeset
   353
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   354
  public void clearCoRoutine(boolean callDoTerminate) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   355
    if (null != m_incrementalSAXSource) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   356
      if (callDoTerminate)
7f561c08de6b Initial load
duke
parents:
diff changeset
   357
        m_incrementalSAXSource.deliverMoreNodes(false);
7f561c08de6b Initial load
duke
parents:
diff changeset
   358
7f561c08de6b Initial load
duke
parents:
diff changeset
   359
      m_incrementalSAXSource = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   360
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   361
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   362
7f561c08de6b Initial load
duke
parents:
diff changeset
   363
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   364
   * Bind a IncrementalSAXSource to this DTM. If we discover we need nodes
7f561c08de6b Initial load
duke
parents:
diff changeset
   365
   * that have not yet been built, we will ask this object to send us more
7f561c08de6b Initial load
duke
parents:
diff changeset
   366
   * events, and it will manage interactions with its data sources.
7f561c08de6b Initial load
duke
parents:
diff changeset
   367
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   368
   * Note that we do not actually build the IncrementalSAXSource, since we don't
7f561c08de6b Initial load
duke
parents:
diff changeset
   369
   * know what source it's reading from, what thread that source will run in,
7f561c08de6b Initial load
duke
parents:
diff changeset
   370
   * or when it will run.
7f561c08de6b Initial load
duke
parents:
diff changeset
   371
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   372
   * @param incrementalSAXSource The parser that we want to recieve events from
7f561c08de6b Initial load
duke
parents:
diff changeset
   373
   * on demand.
7f561c08de6b Initial load
duke
parents:
diff changeset
   374
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   375
  public void setIncrementalSAXSource(IncrementalSAXSource incrementalSAXSource) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   376
    // Establish coroutine link so we can request more data
7f561c08de6b Initial load
duke
parents:
diff changeset
   377
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
   378
    // Note: It's possible that some versions of IncrementalSAXSource may
7f561c08de6b Initial load
duke
parents:
diff changeset
   379
    // not actually use a CoroutineManager, and hence may not require
7f561c08de6b Initial load
duke
parents:
diff changeset
   380
    // that we obtain an Application Coroutine ID. (This relies on the
7f561c08de6b Initial load
duke
parents:
diff changeset
   381
    // coroutine transaction details having been encapsulated in the
7f561c08de6b Initial load
duke
parents:
diff changeset
   382
    // IncrementalSAXSource.do...() methods.)
7f561c08de6b Initial load
duke
parents:
diff changeset
   383
    m_incrementalSAXSource = incrementalSAXSource;
7f561c08de6b Initial load
duke
parents:
diff changeset
   384
7f561c08de6b Initial load
duke
parents:
diff changeset
   385
    // Establish SAX-stream link so we can receive the requested data
7f561c08de6b Initial load
duke
parents:
diff changeset
   386
    incrementalSAXSource.setContentHandler(this);
7f561c08de6b Initial load
duke
parents:
diff changeset
   387
    incrementalSAXSource.setLexicalHandler(this);
7f561c08de6b Initial load
duke
parents:
diff changeset
   388
    incrementalSAXSource.setDTDHandler(this);
7f561c08de6b Initial load
duke
parents:
diff changeset
   389
7f561c08de6b Initial load
duke
parents:
diff changeset
   390
    // Are the following really needed? incrementalSAXSource doesn't yet
7f561c08de6b Initial load
duke
parents:
diff changeset
   391
    // support them, and they're mostly no-ops here...
7f561c08de6b Initial load
duke
parents:
diff changeset
   392
    //incrementalSAXSource.setErrorHandler(this);
7f561c08de6b Initial load
duke
parents:
diff changeset
   393
    //incrementalSAXSource.setDeclHandler(this);
7f561c08de6b Initial load
duke
parents:
diff changeset
   394
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   395
7f561c08de6b Initial load
duke
parents:
diff changeset
   396
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   397
   * getContentHandler returns "our SAX builder" -- the thing that
7f561c08de6b Initial load
duke
parents:
diff changeset
   398
   * someone else should send SAX events to in order to extend this
7f561c08de6b Initial load
duke
parents:
diff changeset
   399
   * DTM model.
7f561c08de6b Initial load
duke
parents:
diff changeset
   400
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   401
   * %REVIEW% Should this return null if constrution already done/begun?
7f561c08de6b Initial load
duke
parents:
diff changeset
   402
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   403
   * @return null if this model doesn't respond to SAX events,
7f561c08de6b Initial load
duke
parents:
diff changeset
   404
   * "this" if the DTM object has a built-in SAX ContentHandler,
7f561c08de6b Initial load
duke
parents:
diff changeset
   405
   * the IncrementalSAXSource if we're bound to one and should receive
7f561c08de6b Initial load
duke
parents:
diff changeset
   406
   * the SAX stream via it for incremental build purposes...
7f561c08de6b Initial load
duke
parents:
diff changeset
   407
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   408
   * Note that IncrementalSAXSource_Filter is package private, hence
7f561c08de6b Initial load
duke
parents:
diff changeset
   409
   * it can be statically referenced using instanceof (CR 6537912).
7f561c08de6b Initial load
duke
parents:
diff changeset
   410
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   411
  public ContentHandler getContentHandler() {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   412
    if (m_incrementalSAXSource.getClass().getName()
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   413
        .equals("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Filter"))
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   414
      return (ContentHandler) m_incrementalSAXSource;
7f561c08de6b Initial load
duke
parents:
diff changeset
   415
    else
7f561c08de6b Initial load
duke
parents:
diff changeset
   416
      return this;
7f561c08de6b Initial load
duke
parents:
diff changeset
   417
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   418
7f561c08de6b Initial load
duke
parents:
diff changeset
   419
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   420
   * Return this DTM's lexical handler.
7f561c08de6b Initial load
duke
parents:
diff changeset
   421
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   422
   * %REVIEW% Should this return null if constrution already done/begun?
7f561c08de6b Initial load
duke
parents:
diff changeset
   423
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   424
   * @return null if this model doesn't respond to lexical SAX events,
7f561c08de6b Initial load
duke
parents:
diff changeset
   425
   * "this" if the DTM object has a built-in SAX ContentHandler,
7f561c08de6b Initial load
duke
parents:
diff changeset
   426
   * the IncrementalSAXSource if we're bound to one and should receive
7f561c08de6b Initial load
duke
parents:
diff changeset
   427
   * the SAX stream via it for incremental build purposes...
7f561c08de6b Initial load
duke
parents:
diff changeset
   428
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   429
   * Note that IncrementalSAXSource_Filter is package private, hence
7f561c08de6b Initial load
duke
parents:
diff changeset
   430
   * it can be statically referenced using instanceof (CR 6537912).
7f561c08de6b Initial load
duke
parents:
diff changeset
   431
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   432
  public LexicalHandler getLexicalHandler() {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   433
    if (m_incrementalSAXSource.getClass().getName()
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   434
        .equals("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Filter"))
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   435
      return (LexicalHandler) m_incrementalSAXSource;
7f561c08de6b Initial load
duke
parents:
diff changeset
   436
    else
7f561c08de6b Initial load
duke
parents:
diff changeset
   437
      return this;
7f561c08de6b Initial load
duke
parents:
diff changeset
   438
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   439
7f561c08de6b Initial load
duke
parents:
diff changeset
   440
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   441
   * Return this DTM's EntityResolver.
7f561c08de6b Initial load
duke
parents:
diff changeset
   442
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   443
   * @return null if this model doesn't respond to SAX entity ref events.
7f561c08de6b Initial load
duke
parents:
diff changeset
   444
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   445
  public EntityResolver getEntityResolver() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   446
    return this;
7f561c08de6b Initial load
duke
parents:
diff changeset
   447
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   448
7f561c08de6b Initial load
duke
parents:
diff changeset
   449
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   450
   * Return this DTM's DTDHandler.
7f561c08de6b Initial load
duke
parents:
diff changeset
   451
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   452
   * @return null if this model doesn't respond to SAX dtd events.
7f561c08de6b Initial load
duke
parents:
diff changeset
   453
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   454
  public DTDHandler getDTDHandler() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   455
    return this;
7f561c08de6b Initial load
duke
parents:
diff changeset
   456
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   457
7f561c08de6b Initial load
duke
parents:
diff changeset
   458
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   459
   * Return this DTM's ErrorHandler.
7f561c08de6b Initial load
duke
parents:
diff changeset
   460
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   461
   * @return null if this model doesn't respond to SAX error events.
7f561c08de6b Initial load
duke
parents:
diff changeset
   462
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   463
  public ErrorHandler getErrorHandler() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   464
    return this;
7f561c08de6b Initial load
duke
parents:
diff changeset
   465
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   466
7f561c08de6b Initial load
duke
parents:
diff changeset
   467
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   468
   * Return this DTM's DeclHandler.
7f561c08de6b Initial load
duke
parents:
diff changeset
   469
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   470
   * @return null if this model doesn't respond to SAX Decl events.
7f561c08de6b Initial load
duke
parents:
diff changeset
   471
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   472
  public DeclHandler getDeclHandler() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   473
    return this;
7f561c08de6b Initial load
duke
parents:
diff changeset
   474
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   475
7f561c08de6b Initial load
duke
parents:
diff changeset
   476
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   477
   * @return true iff we're building this model incrementally (eg
7f561c08de6b Initial load
duke
parents:
diff changeset
   478
   * we're partnered with a IncrementalSAXSource) and thus require that the
7f561c08de6b Initial load
duke
parents:
diff changeset
   479
   * transformation and the parse run simultaneously. Guidance to the
7f561c08de6b Initial load
duke
parents:
diff changeset
   480
   * DTMManager.
7f561c08de6b Initial load
duke
parents:
diff changeset
   481
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   482
  public boolean needsTwoThreads() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   483
    return null != m_incrementalSAXSource;
7f561c08de6b Initial load
duke
parents:
diff changeset
   484
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   485
7f561c08de6b Initial load
duke
parents:
diff changeset
   486
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   487
   * Directly call the
7f561c08de6b Initial load
duke
parents:
diff changeset
   488
   * characters method on the passed ContentHandler for the
7f561c08de6b Initial load
duke
parents:
diff changeset
   489
   * string-value of the given node (see http://www.w3.org/TR/xpath#data-model
7f561c08de6b Initial load
duke
parents:
diff changeset
   490
   * for the definition of a node's string-value). Multiple calls to the
7f561c08de6b Initial load
duke
parents:
diff changeset
   491
   * ContentHandler's characters methods may well occur for a single call to
7f561c08de6b Initial load
duke
parents:
diff changeset
   492
   * this method.
7f561c08de6b Initial load
duke
parents:
diff changeset
   493
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   494
   * @param nodeHandle The node ID.
7f561c08de6b Initial load
duke
parents:
diff changeset
   495
   * @param ch A non-null reference to a ContentHandler.
7f561c08de6b Initial load
duke
parents:
diff changeset
   496
   * @param normalize true if the content should be normalized according to
7f561c08de6b Initial load
duke
parents:
diff changeset
   497
   * the rules for the XPath
7f561c08de6b Initial load
duke
parents:
diff changeset
   498
   * <a href="http://www.w3.org/TR/xpath#function-normalize-space">normalize-space</a>
7f561c08de6b Initial load
duke
parents:
diff changeset
   499
   * function.
7f561c08de6b Initial load
duke
parents:
diff changeset
   500
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   501
   * @throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   502
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   503
  public void dispatchCharactersEvents(int nodeHandle, ContentHandler ch,
7f561c08de6b Initial load
duke
parents:
diff changeset
   504
                                       boolean normalize)
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   505
    throws SAXException
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   506
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   507
    int identity = makeNodeIdentity(nodeHandle);
7f561c08de6b Initial load
duke
parents:
diff changeset
   508
7f561c08de6b Initial load
duke
parents:
diff changeset
   509
    if (identity == DTM.NULL)
7f561c08de6b Initial load
duke
parents:
diff changeset
   510
      return;
7f561c08de6b Initial load
duke
parents:
diff changeset
   511
7f561c08de6b Initial load
duke
parents:
diff changeset
   512
    int type = _type(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
   513
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   514
    if (isTextType(type)) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   515
      int dataIndex = m_dataOrQName.elementAt(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
   516
      int offset = m_data.elementAt(dataIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   517
      int length = m_data.elementAt(dataIndex + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   518
7f561c08de6b Initial load
duke
parents:
diff changeset
   519
      if(normalize)
7f561c08de6b Initial load
duke
parents:
diff changeset
   520
        m_chars.sendNormalizedSAXcharacters(ch, offset, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   521
      else
7f561c08de6b Initial load
duke
parents:
diff changeset
   522
        m_chars.sendSAXcharacters(ch, offset, length);
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   523
    } else {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   524
      int firstChild = _firstch(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
   525
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   526
      if (DTM.NULL != firstChild) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   527
        int offset = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   528
        int length = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
   529
        int startNode = identity;
7f561c08de6b Initial load
duke
parents:
diff changeset
   530
7f561c08de6b Initial load
duke
parents:
diff changeset
   531
        identity = firstChild;
7f561c08de6b Initial load
duke
parents:
diff changeset
   532
7f561c08de6b Initial load
duke
parents:
diff changeset
   533
        do {
7f561c08de6b Initial load
duke
parents:
diff changeset
   534
          type = _type(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
   535
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   536
          if (isTextType(type)) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   537
            int dataIndex = _dataOrQName(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
   538
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   539
            if (-1 == offset) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   540
              offset = m_data.elementAt(dataIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   541
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   542
7f561c08de6b Initial load
duke
parents:
diff changeset
   543
            length += m_data.elementAt(dataIndex + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   544
          }
7f561c08de6b Initial load
duke
parents:
diff changeset
   545
7f561c08de6b Initial load
duke
parents:
diff changeset
   546
          identity = getNextNodeIdentity(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
   547
        } while (DTM.NULL != identity && (_parent(identity) >= startNode));
7f561c08de6b Initial load
duke
parents:
diff changeset
   548
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   549
        if (length > 0) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   550
          if(normalize)
7f561c08de6b Initial load
duke
parents:
diff changeset
   551
            m_chars.sendNormalizedSAXcharacters(ch, offset, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   552
          else
7f561c08de6b Initial load
duke
parents:
diff changeset
   553
            m_chars.sendSAXcharacters(ch, offset, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   554
        }
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   555
      } else if(type != DTM.ELEMENT_NODE) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   556
        int dataIndex = _dataOrQName(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
   557
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   558
        if (dataIndex < 0) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   559
          dataIndex = -dataIndex;
7f561c08de6b Initial load
duke
parents:
diff changeset
   560
          dataIndex = m_data.elementAt(dataIndex + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   561
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   562
7f561c08de6b Initial load
duke
parents:
diff changeset
   563
        String str = m_valuesOrPrefixes.indexToString(dataIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   564
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   565
        if(normalize)
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   566
          FastStringBuffer.sendNormalizedSAXcharacters(str.toCharArray(),
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   567
                                                       0, str.length(), ch);
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   568
        else
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   569
          ch.characters(str.toCharArray(), 0, str.length());
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   570
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   571
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   572
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   573
7f561c08de6b Initial load
duke
parents:
diff changeset
   574
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   575
   * Given a node handle, return its DOM-style node name. This will
7f561c08de6b Initial load
duke
parents:
diff changeset
   576
   * include names such as #text or #document.
7f561c08de6b Initial load
duke
parents:
diff changeset
   577
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   578
   * @param nodeHandle the id of the node.
7f561c08de6b Initial load
duke
parents:
diff changeset
   579
   * @return String Name of this node, which may be an empty string.
7f561c08de6b Initial load
duke
parents:
diff changeset
   580
   * %REVIEW% Document when empty string is possible...
7f561c08de6b Initial load
duke
parents:
diff changeset
   581
   * %REVIEW-COMMENT% It should never be empty, should it?
7f561c08de6b Initial load
duke
parents:
diff changeset
   582
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   583
  public String getNodeName(int nodeHandle) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   584
    int expandedTypeID = getExpandedTypeID(nodeHandle);
7f561c08de6b Initial load
duke
parents:
diff changeset
   585
    // If just testing nonzero, no need to shift...
7f561c08de6b Initial load
duke
parents:
diff changeset
   586
    int namespaceID = m_expandedNameTable.getNamespaceID(expandedTypeID);
7f561c08de6b Initial load
duke
parents:
diff changeset
   587
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   588
    if (0 == namespaceID) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   589
      // Don't retrieve name until/unless needed
7f561c08de6b Initial load
duke
parents:
diff changeset
   590
      // String name = m_expandedNameTable.getLocalName(expandedTypeID);
7f561c08de6b Initial load
duke
parents:
diff changeset
   591
      int type = getNodeType(nodeHandle);
7f561c08de6b Initial load
duke
parents:
diff changeset
   592
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   593
      if (type == DTM.NAMESPACE_NODE) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   594
        if (null == m_expandedNameTable.getLocalName(expandedTypeID))
7f561c08de6b Initial load
duke
parents:
diff changeset
   595
          return "xmlns";
7f561c08de6b Initial load
duke
parents:
diff changeset
   596
        else
7f561c08de6b Initial load
duke
parents:
diff changeset
   597
          return "xmlns:" + m_expandedNameTable.getLocalName(expandedTypeID);
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   598
      } else if (0 == m_expandedNameTable.getLocalNameID(expandedTypeID)) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   599
        return m_fixednames[type];
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   600
      } else
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   601
        return m_expandedNameTable.getLocalName(expandedTypeID);
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   602
    } else {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   603
      int qnameIndex = m_dataOrQName.elementAt(makeNodeIdentity(nodeHandle));
7f561c08de6b Initial load
duke
parents:
diff changeset
   604
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   605
      if (qnameIndex < 0) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   606
        qnameIndex = -qnameIndex;
7f561c08de6b Initial load
duke
parents:
diff changeset
   607
        qnameIndex = m_data.elementAt(qnameIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   608
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   609
7f561c08de6b Initial load
duke
parents:
diff changeset
   610
      return m_valuesOrPrefixes.indexToString(qnameIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   611
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   612
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   613
7f561c08de6b Initial load
duke
parents:
diff changeset
   614
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   615
   * Given a node handle, return the XPath node name.  This should be
7f561c08de6b Initial load
duke
parents:
diff changeset
   616
   * the name as described by the XPath data model, NOT the DOM-style
7f561c08de6b Initial load
duke
parents:
diff changeset
   617
   * name.
7f561c08de6b Initial load
duke
parents:
diff changeset
   618
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   619
   * @param nodeHandle the id of the node.
7f561c08de6b Initial load
duke
parents:
diff changeset
   620
   * @return String Name of this node, which may be an empty string.
7f561c08de6b Initial load
duke
parents:
diff changeset
   621
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   622
  public String getNodeNameX(int nodeHandle) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   623
    int expandedTypeID = getExpandedTypeID(nodeHandle);
7f561c08de6b Initial load
duke
parents:
diff changeset
   624
    int namespaceID = m_expandedNameTable.getNamespaceID(expandedTypeID);
7f561c08de6b Initial load
duke
parents:
diff changeset
   625
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   626
    if (namespaceID == 0) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   627
      String name = m_expandedNameTable.getLocalName(expandedTypeID);
7f561c08de6b Initial load
duke
parents:
diff changeset
   628
7f561c08de6b Initial load
duke
parents:
diff changeset
   629
      if (name == null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   630
        return "";
7f561c08de6b Initial load
duke
parents:
diff changeset
   631
      else
7f561c08de6b Initial load
duke
parents:
diff changeset
   632
        return name;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   633
    } else {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   634
      int qnameIndex = m_dataOrQName.elementAt(makeNodeIdentity(nodeHandle));
7f561c08de6b Initial load
duke
parents:
diff changeset
   635
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   636
      if (qnameIndex < 0) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   637
        qnameIndex = -qnameIndex;
7f561c08de6b Initial load
duke
parents:
diff changeset
   638
        qnameIndex = m_data.elementAt(qnameIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   639
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   640
7f561c08de6b Initial load
duke
parents:
diff changeset
   641
      return m_valuesOrPrefixes.indexToString(qnameIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   642
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   643
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   644
7f561c08de6b Initial load
duke
parents:
diff changeset
   645
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   646
   *     5. [specified] A flag indicating whether this attribute was actually
7f561c08de6b Initial load
duke
parents:
diff changeset
   647
   *        specified in the start-tag of its element, or was defaulted from the
7f561c08de6b Initial load
duke
parents:
diff changeset
   648
   *        DTD.
7f561c08de6b Initial load
duke
parents:
diff changeset
   649
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   650
   * @param attributeHandle Must be a valid handle to an attribute node.
7f561c08de6b Initial load
duke
parents:
diff changeset
   651
   * @return <code>true</code> if the attribute was specified;
7f561c08de6b Initial load
duke
parents:
diff changeset
   652
   *         <code>false</code> if it was defaulted.
7f561c08de6b Initial load
duke
parents:
diff changeset
   653
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   654
  public boolean isAttributeSpecified(int attributeHandle) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   655
    // I'm not sure if I want to do anything with this...
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   656
    return true; // ??
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   657
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   658
7f561c08de6b Initial load
duke
parents:
diff changeset
   659
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   660
   *   A document type declaration information item has the following properties:
7f561c08de6b Initial load
duke
parents:
diff changeset
   661
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   662
   *     1. [system identifier] The system identifier of the external subset, if
7f561c08de6b Initial load
duke
parents:
diff changeset
   663
   *        it exists. Otherwise this property has no value.
7f561c08de6b Initial load
duke
parents:
diff changeset
   664
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   665
   * @return the system identifier String object, or null if there is none.
7f561c08de6b Initial load
duke
parents:
diff changeset
   666
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   667
  public String getDocumentTypeDeclarationSystemIdentifier() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   668
    /** @todo: implement this com.sun.org.apache.xml.internal.dtm.DTMDefaultBase abstract method */
7f561c08de6b Initial load
duke
parents:
diff changeset
   669
    error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"Not yet supported!");
7f561c08de6b Initial load
duke
parents:
diff changeset
   670
7f561c08de6b Initial load
duke
parents:
diff changeset
   671
    return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   672
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   673
7f561c08de6b Initial load
duke
parents:
diff changeset
   674
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   675
   * Get the next node identity value in the list, and call the iterator
7f561c08de6b Initial load
duke
parents:
diff changeset
   676
   * if it hasn't been added yet.
7f561c08de6b Initial load
duke
parents:
diff changeset
   677
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   678
   * @param identity The node identity (index).
7f561c08de6b Initial load
duke
parents:
diff changeset
   679
   * @return identity+1, or DTM.NULL.
7f561c08de6b Initial load
duke
parents:
diff changeset
   680
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   681
  protected int getNextNodeIdentity(int identity) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   682
    identity += 1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   683
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   684
    while (identity >= m_size) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   685
      if (m_incrementalSAXSource == null)
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   686
        return DTM.NULL;
7f561c08de6b Initial load
duke
parents:
diff changeset
   687
7f561c08de6b Initial load
duke
parents:
diff changeset
   688
      nextNode();
7f561c08de6b Initial load
duke
parents:
diff changeset
   689
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   690
7f561c08de6b Initial load
duke
parents:
diff changeset
   691
    return identity;
7f561c08de6b Initial load
duke
parents:
diff changeset
   692
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   693
7f561c08de6b Initial load
duke
parents:
diff changeset
   694
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   695
   * Directly create SAX parser events from a subtree.
7f561c08de6b Initial load
duke
parents:
diff changeset
   696
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   697
   * @param nodeHandle The node ID.
7f561c08de6b Initial load
duke
parents:
diff changeset
   698
   * @param ch A non-null reference to a ContentHandler.
7f561c08de6b Initial load
duke
parents:
diff changeset
   699
   *
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   700
   * @throws SAXException
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   701
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   702
  public void dispatchToEvents(int nodeHandle, ContentHandler ch)
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
   703
          throws SAXException
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   704
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   705
7f561c08de6b Initial load
duke
parents:
diff changeset
   706
    DTMTreeWalker treeWalker = m_walker;
7f561c08de6b Initial load
duke
parents:
diff changeset
   707
    ContentHandler prevCH = treeWalker.getcontentHandler();
7f561c08de6b Initial load
duke
parents:
diff changeset
   708
7f561c08de6b Initial load
duke
parents:
diff changeset
   709
    if (null != prevCH)
7f561c08de6b Initial load
duke
parents:
diff changeset
   710
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   711
      treeWalker = new DTMTreeWalker();
7f561c08de6b Initial load
duke
parents:
diff changeset
   712
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   713
7f561c08de6b Initial load
duke
parents:
diff changeset
   714
    treeWalker.setcontentHandler(ch);
7f561c08de6b Initial load
duke
parents:
diff changeset
   715
    treeWalker.setDTM(this);
7f561c08de6b Initial load
duke
parents:
diff changeset
   716
7f561c08de6b Initial load
duke
parents:
diff changeset
   717
    try
7f561c08de6b Initial load
duke
parents:
diff changeset
   718
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   719
      treeWalker.traverse(nodeHandle);
7f561c08de6b Initial load
duke
parents:
diff changeset
   720
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   721
    finally
7f561c08de6b Initial load
duke
parents:
diff changeset
   722
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   723
      treeWalker.setcontentHandler(null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   724
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   725
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   726
7f561c08de6b Initial load
duke
parents:
diff changeset
   727
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   728
   * Get the number of nodes that have been added.
7f561c08de6b Initial load
duke
parents:
diff changeset
   729
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   730
   * @return The number of that are currently in the tree.
7f561c08de6b Initial load
duke
parents:
diff changeset
   731
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   732
  public int getNumberOfNodes()
7f561c08de6b Initial load
duke
parents:
diff changeset
   733
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   734
    return m_size;
7f561c08de6b Initial load
duke
parents:
diff changeset
   735
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   736
7f561c08de6b Initial load
duke
parents:
diff changeset
   737
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   738
   * This method should try and build one or more nodes in the table.
7f561c08de6b Initial load
duke
parents:
diff changeset
   739
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   740
   * @return The true if a next node is found or false if
7f561c08de6b Initial load
duke
parents:
diff changeset
   741
   *         there are no more nodes.
7f561c08de6b Initial load
duke
parents:
diff changeset
   742
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   743
  protected boolean nextNode()
7f561c08de6b Initial load
duke
parents:
diff changeset
   744
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   745
7f561c08de6b Initial load
duke
parents:
diff changeset
   746
    if (null == m_incrementalSAXSource)
7f561c08de6b Initial load
duke
parents:
diff changeset
   747
      return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   748
7f561c08de6b Initial load
duke
parents:
diff changeset
   749
    if (m_endDocumentOccured)
7f561c08de6b Initial load
duke
parents:
diff changeset
   750
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   751
      clearCoRoutine();
7f561c08de6b Initial load
duke
parents:
diff changeset
   752
7f561c08de6b Initial load
duke
parents:
diff changeset
   753
      return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   754
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   755
7f561c08de6b Initial load
duke
parents:
diff changeset
   756
    Object gotMore = m_incrementalSAXSource.deliverMoreNodes(true);
7f561c08de6b Initial load
duke
parents:
diff changeset
   757
7f561c08de6b Initial load
duke
parents:
diff changeset
   758
    // gotMore may be a Boolean (TRUE if still parsing, FALSE if
7f561c08de6b Initial load
duke
parents:
diff changeset
   759
    // EOF) or an exception if IncrementalSAXSource malfunctioned
7f561c08de6b Initial load
duke
parents:
diff changeset
   760
    // (code error rather than user error).
7f561c08de6b Initial load
duke
parents:
diff changeset
   761
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
   762
    // %REVIEW% Currently the ErrorHandlers sketched herein are
7f561c08de6b Initial load
duke
parents:
diff changeset
   763
    // no-ops, so I'm going to initially leave this also as a
7f561c08de6b Initial load
duke
parents:
diff changeset
   764
    // no-op.
7f561c08de6b Initial load
duke
parents:
diff changeset
   765
    if (!(gotMore instanceof Boolean))
7f561c08de6b Initial load
duke
parents:
diff changeset
   766
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   767
      if(gotMore instanceof RuntimeException)
7f561c08de6b Initial load
duke
parents:
diff changeset
   768
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   769
        throw (RuntimeException)gotMore;
7f561c08de6b Initial load
duke
parents:
diff changeset
   770
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   771
      else if(gotMore instanceof Exception)
7f561c08de6b Initial load
duke
parents:
diff changeset
   772
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   773
        throw new WrappedRuntimeException((Exception)gotMore);
7f561c08de6b Initial load
duke
parents:
diff changeset
   774
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   775
      // for now...
7f561c08de6b Initial load
duke
parents:
diff changeset
   776
      clearCoRoutine();
7f561c08de6b Initial load
duke
parents:
diff changeset
   777
7f561c08de6b Initial load
duke
parents:
diff changeset
   778
      return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   779
7f561c08de6b Initial load
duke
parents:
diff changeset
   780
      // %TBD%
7f561c08de6b Initial load
duke
parents:
diff changeset
   781
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   782
7f561c08de6b Initial load
duke
parents:
diff changeset
   783
    if (gotMore != Boolean.TRUE)
7f561c08de6b Initial load
duke
parents:
diff changeset
   784
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   785
7f561c08de6b Initial load
duke
parents:
diff changeset
   786
      // EOF reached without satisfying the request
7f561c08de6b Initial load
duke
parents:
diff changeset
   787
      clearCoRoutine();  // Drop connection, stop trying
7f561c08de6b Initial load
duke
parents:
diff changeset
   788
7f561c08de6b Initial load
duke
parents:
diff changeset
   789
      // %TBD% deregister as its listener?
7f561c08de6b Initial load
duke
parents:
diff changeset
   790
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   791
7f561c08de6b Initial load
duke
parents:
diff changeset
   792
    return true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   793
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   794
7f561c08de6b Initial load
duke
parents:
diff changeset
   795
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   796
   * Bottleneck determination of text type.
7f561c08de6b Initial load
duke
parents:
diff changeset
   797
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   798
   * @param type oneof DTM.XXX_NODE.
7f561c08de6b Initial load
duke
parents:
diff changeset
   799
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   800
   * @return true if this is a text or cdata section.
7f561c08de6b Initial load
duke
parents:
diff changeset
   801
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   802
  private final boolean isTextType(int type)
7f561c08de6b Initial load
duke
parents:
diff changeset
   803
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   804
    return (DTM.TEXT_NODE == type || DTM.CDATA_SECTION_NODE == type);
7f561c08de6b Initial load
duke
parents:
diff changeset
   805
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   806
7f561c08de6b Initial load
duke
parents:
diff changeset
   807
//    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   808
//     * Ensure that the size of the information arrays can hold another entry
7f561c08de6b Initial load
duke
parents:
diff changeset
   809
//     * at the given index.
7f561c08de6b Initial load
duke
parents:
diff changeset
   810
//     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   811
//     * @param on exit from this function, the information arrays sizes must be
7f561c08de6b Initial load
duke
parents:
diff changeset
   812
//     * at least index+1.
7f561c08de6b Initial load
duke
parents:
diff changeset
   813
//     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   814
//     * NEEDSDOC @param index
7f561c08de6b Initial load
duke
parents:
diff changeset
   815
//     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   816
//    protected void ensureSize(int index)
7f561c08de6b Initial load
duke
parents:
diff changeset
   817
//    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   818
//          // dataOrQName is an SuballocatedIntVector and hence self-sizing.
7f561c08de6b Initial load
duke
parents:
diff changeset
   819
//          // But DTMDefaultBase may need fixup.
7f561c08de6b Initial load
duke
parents:
diff changeset
   820
//        super.ensureSize(index);
7f561c08de6b Initial load
duke
parents:
diff changeset
   821
//    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   822
7f561c08de6b Initial load
duke
parents:
diff changeset
   823
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   824
   * Construct the node map from the node.
7f561c08de6b Initial load
duke
parents:
diff changeset
   825
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   826
   * @param type raw type ID, one of DTM.XXX_NODE.
7f561c08de6b Initial load
duke
parents:
diff changeset
   827
   * @param expandedTypeID The expended type ID.
7f561c08de6b Initial load
duke
parents:
diff changeset
   828
   * @param parentIndex The current parent index.
7f561c08de6b Initial load
duke
parents:
diff changeset
   829
   * @param previousSibling The previous sibling index.
7f561c08de6b Initial load
duke
parents:
diff changeset
   830
   * @param dataOrPrefix index into m_data table, or string handle.
7f561c08de6b Initial load
duke
parents:
diff changeset
   831
   * @param canHaveFirstChild true if the node can have a first child, false
7f561c08de6b Initial load
duke
parents:
diff changeset
   832
   *                          if it is atomic.
7f561c08de6b Initial load
duke
parents:
diff changeset
   833
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   834
   * @return The index identity of the node that was added.
7f561c08de6b Initial load
duke
parents:
diff changeset
   835
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   836
  protected int addNode(int type, int expandedTypeID,
7f561c08de6b Initial load
duke
parents:
diff changeset
   837
                        int parentIndex, int previousSibling,
7f561c08de6b Initial load
duke
parents:
diff changeset
   838
                        int dataOrPrefix, boolean canHaveFirstChild)
7f561c08de6b Initial load
duke
parents:
diff changeset
   839
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   840
    // Common to all nodes:
7f561c08de6b Initial load
duke
parents:
diff changeset
   841
    int nodeIndex = m_size++;
7f561c08de6b Initial load
duke
parents:
diff changeset
   842
7f561c08de6b Initial load
duke
parents:
diff changeset
   843
    // Have we overflowed a DTM Identity's addressing range?
7f561c08de6b Initial load
duke
parents:
diff changeset
   844
    if(m_dtmIdent.size() == (nodeIndex>>>DTMManager.IDENT_DTM_NODE_BITS))
7f561c08de6b Initial load
duke
parents:
diff changeset
   845
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   846
      addNewDTMID(nodeIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   847
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   848
7f561c08de6b Initial load
duke
parents:
diff changeset
   849
    m_firstch.addElement(canHaveFirstChild ? NOTPROCESSED : DTM.NULL);
7f561c08de6b Initial load
duke
parents:
diff changeset
   850
    m_nextsib.addElement(NOTPROCESSED);
7f561c08de6b Initial load
duke
parents:
diff changeset
   851
    m_parent.addElement(parentIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   852
    m_exptype.addElement(expandedTypeID);
7f561c08de6b Initial load
duke
parents:
diff changeset
   853
    m_dataOrQName.addElement(dataOrPrefix);
7f561c08de6b Initial load
duke
parents:
diff changeset
   854
7f561c08de6b Initial load
duke
parents:
diff changeset
   855
    if (m_prevsib != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   856
      m_prevsib.addElement(previousSibling);
7f561c08de6b Initial load
duke
parents:
diff changeset
   857
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   858
7f561c08de6b Initial load
duke
parents:
diff changeset
   859
    if (DTM.NULL != previousSibling) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   860
      m_nextsib.setElementAt(nodeIndex,previousSibling);
7f561c08de6b Initial load
duke
parents:
diff changeset
   861
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   862
7f561c08de6b Initial load
duke
parents:
diff changeset
   863
    if (m_locator != null && m_useSourceLocationProperty) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   864
      setSourceLocation();
7f561c08de6b Initial load
duke
parents:
diff changeset
   865
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   866
7f561c08de6b Initial load
duke
parents:
diff changeset
   867
    // Note that nextSibling is not processed until charactersFlush()
7f561c08de6b Initial load
duke
parents:
diff changeset
   868
    // is called, to handle successive characters() events.
7f561c08de6b Initial load
duke
parents:
diff changeset
   869
7f561c08de6b Initial load
duke
parents:
diff changeset
   870
    // Special handling by type: Declare namespaces, attach first child
7f561c08de6b Initial load
duke
parents:
diff changeset
   871
    switch(type)
7f561c08de6b Initial load
duke
parents:
diff changeset
   872
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   873
    case DTM.NAMESPACE_NODE:
7f561c08de6b Initial load
duke
parents:
diff changeset
   874
      declareNamespaceInContext(parentIndex,nodeIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   875
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   876
    case DTM.ATTRIBUTE_NODE:
7f561c08de6b Initial load
duke
parents:
diff changeset
   877
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   878
    default:
7f561c08de6b Initial load
duke
parents:
diff changeset
   879
      if (DTM.NULL == previousSibling && DTM.NULL != parentIndex) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   880
        m_firstch.setElementAt(nodeIndex,parentIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   881
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   882
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   883
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   884
7f561c08de6b Initial load
duke
parents:
diff changeset
   885
    return nodeIndex;
7f561c08de6b Initial load
duke
parents:
diff changeset
   886
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   887
7f561c08de6b Initial load
duke
parents:
diff changeset
   888
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   889
   * Get a new DTM ID beginning at the specified node index.
7f561c08de6b Initial load
duke
parents:
diff changeset
   890
   * @param  nodeIndex The node identity at which the new DTM ID will begin
7f561c08de6b Initial load
duke
parents:
diff changeset
   891
   * addressing.
7f561c08de6b Initial load
duke
parents:
diff changeset
   892
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   893
  protected void addNewDTMID(int nodeIndex) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   894
    try
7f561c08de6b Initial load
duke
parents:
diff changeset
   895
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   896
      if(m_mgr==null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   897
        throw new ClassCastException();
7f561c08de6b Initial load
duke
parents:
diff changeset
   898
7f561c08de6b Initial load
duke
parents:
diff changeset
   899
                              // Handle as Extended Addressing
7f561c08de6b Initial load
duke
parents:
diff changeset
   900
      DTMManagerDefault mgrD=(DTMManagerDefault)m_mgr;
7f561c08de6b Initial load
duke
parents:
diff changeset
   901
      int id=mgrD.getFirstFreeDTMID();
7f561c08de6b Initial load
duke
parents:
diff changeset
   902
      mgrD.addDTM(this,id,nodeIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   903
      m_dtmIdent.addElement(id<<DTMManager.IDENT_DTM_NODE_BITS);
7f561c08de6b Initial load
duke
parents:
diff changeset
   904
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   905
    catch(ClassCastException e)
7f561c08de6b Initial load
duke
parents:
diff changeset
   906
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   907
      // %REVIEW% Wrong error message, but I've been told we're trying
7f561c08de6b Initial load
duke
parents:
diff changeset
   908
      // not to add messages right not for I18N reasons.
7f561c08de6b Initial load
duke
parents:
diff changeset
   909
      // %REVIEW% Should this be a Fatal Error?
7f561c08de6b Initial load
duke
parents:
diff changeset
   910
      error(XMLMessages.createXMLMessage(XMLErrorResources.ER_NO_DTMIDS_AVAIL, null));//"No more DTM IDs are available";
7f561c08de6b Initial load
duke
parents:
diff changeset
   911
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   912
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   913
7f561c08de6b Initial load
duke
parents:
diff changeset
   914
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   915
    * Migrate a DTM built with an old DTMManager to a new DTMManager.
7f561c08de6b Initial load
duke
parents:
diff changeset
   916
    * After the migration, the new DTMManager will treat the DTM as
7f561c08de6b Initial load
duke
parents:
diff changeset
   917
    * one that is built by itself.
7f561c08de6b Initial load
duke
parents:
diff changeset
   918
    * This is used to support DTM sharing between multiple transformations.
7f561c08de6b Initial load
duke
parents:
diff changeset
   919
    * @param manager the DTMManager
7f561c08de6b Initial load
duke
parents:
diff changeset
   920
    */
7f561c08de6b Initial load
duke
parents:
diff changeset
   921
  public void migrateTo(DTMManager manager) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   922
    super.migrateTo(manager);
7f561c08de6b Initial load
duke
parents:
diff changeset
   923
7f561c08de6b Initial load
duke
parents:
diff changeset
   924
    // We have to reset the information in m_dtmIdent and
7f561c08de6b Initial load
duke
parents:
diff changeset
   925
    // register the DTM with the new manager.
7f561c08de6b Initial load
duke
parents:
diff changeset
   926
    int numDTMs = m_dtmIdent.size();
7f561c08de6b Initial load
duke
parents:
diff changeset
   927
    int dtmId = m_mgrDefault.getFirstFreeDTMID();
7f561c08de6b Initial load
duke
parents:
diff changeset
   928
    int nodeIndex = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
   929
    for (int i = 0; i < numDTMs; i++)
7f561c08de6b Initial load
duke
parents:
diff changeset
   930
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   931
      m_dtmIdent.setElementAt(dtmId << DTMManager.IDENT_DTM_NODE_BITS, i);
7f561c08de6b Initial load
duke
parents:
diff changeset
   932
      m_mgrDefault.addDTM(this, dtmId, nodeIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   933
      dtmId++;
7f561c08de6b Initial load
duke
parents:
diff changeset
   934
      nodeIndex += (1 << DTMManager.IDENT_DTM_NODE_BITS);
7f561c08de6b Initial load
duke
parents:
diff changeset
   935
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   936
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   937
7f561c08de6b Initial load
duke
parents:
diff changeset
   938
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   939
   * Store the source location of the current node.  This method must be called
7f561c08de6b Initial load
duke
parents:
diff changeset
   940
   * as every node is added to the DTM or for no node.
7f561c08de6b Initial load
duke
parents:
diff changeset
   941
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   942
  protected void setSourceLocation() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   943
    m_sourceSystemId.addElement(m_locator.getSystemId());
7f561c08de6b Initial load
duke
parents:
diff changeset
   944
    m_sourceLine.addElement(m_locator.getLineNumber());
7f561c08de6b Initial load
duke
parents:
diff changeset
   945
    m_sourceColumn.addElement(m_locator.getColumnNumber());
7f561c08de6b Initial load
duke
parents:
diff changeset
   946
7f561c08de6b Initial load
duke
parents:
diff changeset
   947
    //%REVIEW% %BUG% Prevent this from arising in the first place
7f561c08de6b Initial load
duke
parents:
diff changeset
   948
    // by not allowing the enabling conditions to change after we start
7f561c08de6b Initial load
duke
parents:
diff changeset
   949
    // building the document.
7f561c08de6b Initial load
duke
parents:
diff changeset
   950
    if (m_sourceSystemId.size() != m_size) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   951
        String msg = "CODING ERROR in Source Location: " + m_size + " != "
7f561c08de6b Initial load
duke
parents:
diff changeset
   952
                    + m_sourceSystemId.size();
7f561c08de6b Initial load
duke
parents:
diff changeset
   953
        System.err.println(msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   954
        throw new RuntimeException(msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   955
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   956
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   957
7f561c08de6b Initial load
duke
parents:
diff changeset
   958
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   959
   * Given a node handle, return its node value. This is mostly
7f561c08de6b Initial load
duke
parents:
diff changeset
   960
   * as defined by the DOM, but may ignore some conveniences.
7f561c08de6b Initial load
duke
parents:
diff changeset
   961
   * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   962
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   963
   * @param nodeHandle The node id.
7f561c08de6b Initial load
duke
parents:
diff changeset
   964
   * @return String Value of this node, or null if not
7f561c08de6b Initial load
duke
parents:
diff changeset
   965
   * meaningful for this node type.
7f561c08de6b Initial load
duke
parents:
diff changeset
   966
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   967
  public String getNodeValue(int nodeHandle)
7f561c08de6b Initial load
duke
parents:
diff changeset
   968
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   969
7f561c08de6b Initial load
duke
parents:
diff changeset
   970
    int identity = makeNodeIdentity(nodeHandle);
7f561c08de6b Initial load
duke
parents:
diff changeset
   971
    int type = _type(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
   972
7f561c08de6b Initial load
duke
parents:
diff changeset
   973
    if (isTextType(type))
7f561c08de6b Initial load
duke
parents:
diff changeset
   974
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   975
      int dataIndex = _dataOrQName(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
   976
      int offset = m_data.elementAt(dataIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   977
      int length = m_data.elementAt(dataIndex + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   978
7f561c08de6b Initial load
duke
parents:
diff changeset
   979
      // %OPT% We should cache this, I guess.
7f561c08de6b Initial load
duke
parents:
diff changeset
   980
      return m_chars.getString(offset, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   981
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   982
    else if (DTM.ELEMENT_NODE == type || DTM.DOCUMENT_FRAGMENT_NODE == type
7f561c08de6b Initial load
duke
parents:
diff changeset
   983
             || DTM.DOCUMENT_NODE == type)
7f561c08de6b Initial load
duke
parents:
diff changeset
   984
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   985
      return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   986
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   987
    else
7f561c08de6b Initial load
duke
parents:
diff changeset
   988
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   989
      int dataIndex = _dataOrQName(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
   990
7f561c08de6b Initial load
duke
parents:
diff changeset
   991
      if (dataIndex < 0)
7f561c08de6b Initial load
duke
parents:
diff changeset
   992
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   993
        dataIndex = -dataIndex;
7f561c08de6b Initial load
duke
parents:
diff changeset
   994
        dataIndex = m_data.elementAt(dataIndex + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   995
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   996
7f561c08de6b Initial load
duke
parents:
diff changeset
   997
      return m_valuesOrPrefixes.indexToString(dataIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
   998
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   999
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1000
7f561c08de6b Initial load
duke
parents:
diff changeset
  1001
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1002
   * Given a node handle, return its XPath-style localname.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1003
   * (As defined in Namespaces, this is the portion of the name after any
7f561c08de6b Initial load
duke
parents:
diff changeset
  1004
   * colon character).
7f561c08de6b Initial load
duke
parents:
diff changeset
  1005
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1006
   * @param nodeHandle the id of the node.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1007
   * @return String Local name of this node.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1008
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1009
  public String getLocalName(int nodeHandle)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1010
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1011
    return m_expandedNameTable.getLocalName(_exptype(makeNodeIdentity(nodeHandle)));
7f561c08de6b Initial load
duke
parents:
diff changeset
  1012
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1013
7f561c08de6b Initial load
duke
parents:
diff changeset
  1014
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1015
   * The getUnparsedEntityURI function returns the URI of the unparsed
7f561c08de6b Initial load
duke
parents:
diff changeset
  1016
   * entity with the specified name in the same document as the context
7f561c08de6b Initial load
duke
parents:
diff changeset
  1017
   * node (see [3.3 Unparsed Entities]). It returns the empty string if
7f561c08de6b Initial load
duke
parents:
diff changeset
  1018
   * there is no such entity.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1019
   * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1020
   * XML processors may choose to use the System Identifier (if one
7f561c08de6b Initial load
duke
parents:
diff changeset
  1021
   * is provided) to resolve the entity, rather than the URI in the
7f561c08de6b Initial load
duke
parents:
diff changeset
  1022
   * Public Identifier. The details are dependent on the processor, and
7f561c08de6b Initial load
duke
parents:
diff changeset
  1023
   * we would have to support some form of plug-in resolver to handle
7f561c08de6b Initial load
duke
parents:
diff changeset
  1024
   * this properly. Currently, we simply return the System Identifier if
7f561c08de6b Initial load
duke
parents:
diff changeset
  1025
   * present, and hope that it a usable URI or that our caller can
7f561c08de6b Initial load
duke
parents:
diff changeset
  1026
   * map it to one.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1027
   * TODO: Resolve Public Identifiers... or consider changing function name.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1028
   * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1029
   * If we find a relative URI
7f561c08de6b Initial load
duke
parents:
diff changeset
  1030
   * reference, XML expects it to be resolved in terms of the base URI
7f561c08de6b Initial load
duke
parents:
diff changeset
  1031
   * of the document. The DOM doesn't do that for us, and it isn't
7f561c08de6b Initial load
duke
parents:
diff changeset
  1032
   * entirely clear whether that should be done here; currently that's
7f561c08de6b Initial load
duke
parents:
diff changeset
  1033
   * pushed up to a higher level of our application. (Note that DOM Level
7f561c08de6b Initial load
duke
parents:
diff changeset
  1034
   * 1 didn't store the document's base URI.)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1035
   * TODO: Consider resolving Relative URIs.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1036
   * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1037
   * (The DOM's statement that "An XML processor may choose to
7f561c08de6b Initial load
duke
parents:
diff changeset
  1038
   * completely expand entities before the structure model is passed
7f561c08de6b Initial load
duke
parents:
diff changeset
  1039
   * to the DOM" refers only to parsed entities, not unparsed, and hence
7f561c08de6b Initial load
duke
parents:
diff changeset
  1040
   * doesn't affect this function.)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1041
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1042
   * @param name A string containing the Entity Name of the unparsed
7f561c08de6b Initial load
duke
parents:
diff changeset
  1043
   * entity.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1044
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1045
   * @return String containing the URI of the Unparsed Entity, or an
7f561c08de6b Initial load
duke
parents:
diff changeset
  1046
   * empty string if no such entity exists.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1047
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1048
  public String getUnparsedEntityURI(String name) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1049
    String url = "";
7f561c08de6b Initial load
duke
parents:
diff changeset
  1050
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1051
    if (null == m_entities) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1052
      return url;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1053
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1054
7f561c08de6b Initial load
duke
parents:
diff changeset
  1055
    int n = m_entities.size();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1056
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1057
    for (int i = 0; i < n; i += ENTITY_FIELDS_PER) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1058
      String ename = m_entities.get(i + ENTITY_FIELD_NAME);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1059
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1060
      if (null != ename && ename.equals(name)) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1061
        String nname = m_entities.get(i + ENTITY_FIELD_NOTATIONNAME);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1062
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1063
        if (null != nname) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1064
          // The draft says: "The XSLT processor may use the public
7f561c08de6b Initial load
duke
parents:
diff changeset
  1065
          // identifier to generate a URI for the entity instead of the URI
7f561c08de6b Initial load
duke
parents:
diff changeset
  1066
          // specified in the system identifier. If the XSLT processor does
7f561c08de6b Initial load
duke
parents:
diff changeset
  1067
          // not use the public identifier to generate the URI, it must use
7f561c08de6b Initial load
duke
parents:
diff changeset
  1068
          // the system identifier; if the system identifier is a relative
7f561c08de6b Initial load
duke
parents:
diff changeset
  1069
          // URI, it must be resolved into an absolute URI using the URI of
7f561c08de6b Initial load
duke
parents:
diff changeset
  1070
          // the resource containing the entity declaration as the base
7f561c08de6b Initial load
duke
parents:
diff changeset
  1071
          // URI [RFC2396]."
7f561c08de6b Initial load
duke
parents:
diff changeset
  1072
          // So I'm falling a bit short here.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1073
          url = m_entities.get(i + ENTITY_FIELD_SYSTEMID);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1074
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1075
          if (null == url) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1076
            url = m_entities.get(i + ENTITY_FIELD_PUBLICID);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1077
          }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1078
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1079
7f561c08de6b Initial load
duke
parents:
diff changeset
  1080
        break;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1081
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1082
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1083
7f561c08de6b Initial load
duke
parents:
diff changeset
  1084
    return url;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1085
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1086
7f561c08de6b Initial load
duke
parents:
diff changeset
  1087
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1088
   * Given a namespace handle, return the prefix that the namespace decl is
7f561c08de6b Initial load
duke
parents:
diff changeset
  1089
   * mapping.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1090
   * Given a node handle, return the prefix used to map to the namespace.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1091
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1092
   * <p> %REVIEW% Are you sure you want "" for no prefix?  </p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1093
   * <p> %REVIEW-COMMENT% I think so... not totally sure. -sb  </p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1094
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1095
   * @param nodeHandle the id of the node.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1096
   * @return String prefix of this node's name, or "" if no explicit
7f561c08de6b Initial load
duke
parents:
diff changeset
  1097
   * namespace prefix was given.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1098
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1099
  public String getPrefix(int nodeHandle)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1100
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1101
7f561c08de6b Initial load
duke
parents:
diff changeset
  1102
    int identity = makeNodeIdentity(nodeHandle);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1103
    int type = _type(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1104
7f561c08de6b Initial load
duke
parents:
diff changeset
  1105
    if (DTM.ELEMENT_NODE == type)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1106
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1107
      int prefixIndex = _dataOrQName(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1108
7f561c08de6b Initial load
duke
parents:
diff changeset
  1109
      if (0 == prefixIndex)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1110
        return "";
7f561c08de6b Initial load
duke
parents:
diff changeset
  1111
      else
7f561c08de6b Initial load
duke
parents:
diff changeset
  1112
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1113
        String qname = m_valuesOrPrefixes.indexToString(prefixIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1114
7f561c08de6b Initial load
duke
parents:
diff changeset
  1115
        return getPrefix(qname, null);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1116
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1117
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1118
    else if (DTM.ATTRIBUTE_NODE == type)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1119
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1120
      int prefixIndex = _dataOrQName(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1121
7f561c08de6b Initial load
duke
parents:
diff changeset
  1122
      if (prefixIndex < 0)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1123
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1124
        prefixIndex = m_data.elementAt(-prefixIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1125
7f561c08de6b Initial load
duke
parents:
diff changeset
  1126
        String qname = m_valuesOrPrefixes.indexToString(prefixIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1127
7f561c08de6b Initial load
duke
parents:
diff changeset
  1128
        return getPrefix(qname, null);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1129
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1130
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1131
7f561c08de6b Initial load
duke
parents:
diff changeset
  1132
    return "";
7f561c08de6b Initial load
duke
parents:
diff changeset
  1133
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1134
7f561c08de6b Initial load
duke
parents:
diff changeset
  1135
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1136
   * Retrieves an attribute node by by qualified name and namespace URI.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1137
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1138
   * @param nodeHandle int Handle of the node upon which to look up this attribute..
7f561c08de6b Initial load
duke
parents:
diff changeset
  1139
   * @param namespaceURI The namespace URI of the attribute to
7f561c08de6b Initial load
duke
parents:
diff changeset
  1140
   *   retrieve, or null.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1141
   * @param name The local name of the attribute to
7f561c08de6b Initial load
duke
parents:
diff changeset
  1142
   *   retrieve.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1143
   * @return The attribute node handle with the specified name (
7f561c08de6b Initial load
duke
parents:
diff changeset
  1144
   *   <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
7f561c08de6b Initial load
duke
parents:
diff changeset
  1145
   *   attribute.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1146
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1147
  public int getAttributeNode(int nodeHandle, String namespaceURI,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1148
                              String name)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1149
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1150
7f561c08de6b Initial load
duke
parents:
diff changeset
  1151
    for (int attrH = getFirstAttribute(nodeHandle); DTM.NULL != attrH;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1152
            attrH = getNextAttribute(attrH))
7f561c08de6b Initial load
duke
parents:
diff changeset
  1153
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1154
      String attrNS = getNamespaceURI(attrH);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1155
      String attrName = getLocalName(attrH);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1156
      boolean nsMatch = namespaceURI == attrNS
7f561c08de6b Initial load
duke
parents:
diff changeset
  1157
                        || (namespaceURI != null
7f561c08de6b Initial load
duke
parents:
diff changeset
  1158
                            && namespaceURI.equals(attrNS));
7f561c08de6b Initial load
duke
parents:
diff changeset
  1159
7f561c08de6b Initial load
duke
parents:
diff changeset
  1160
      if (nsMatch && name.equals(attrName))
7f561c08de6b Initial load
duke
parents:
diff changeset
  1161
        return attrH;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1162
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1163
7f561c08de6b Initial load
duke
parents:
diff changeset
  1164
    return DTM.NULL;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1165
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1166
7f561c08de6b Initial load
duke
parents:
diff changeset
  1167
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1168
   * Return the public identifier of the external subset,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1169
   * normalized as described in 4.2.2 External Entities [XML]. If there is
7f561c08de6b Initial load
duke
parents:
diff changeset
  1170
   * no external subset or if it has no public identifier, this property
7f561c08de6b Initial load
duke
parents:
diff changeset
  1171
   * has no value.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1172
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1173
   * @return the public identifier String object, or null if there is none.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1174
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1175
  public String getDocumentTypeDeclarationPublicIdentifier()
7f561c08de6b Initial load
duke
parents:
diff changeset
  1176
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1177
7f561c08de6b Initial load
duke
parents:
diff changeset
  1178
    /** @todo: implement this com.sun.org.apache.xml.internal.dtm.DTMDefaultBase abstract method */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1179
    error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"Not yet supported!");
7f561c08de6b Initial load
duke
parents:
diff changeset
  1180
7f561c08de6b Initial load
duke
parents:
diff changeset
  1181
    return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1182
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1183
7f561c08de6b Initial load
duke
parents:
diff changeset
  1184
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1185
   * Given a node handle, return its DOM-style namespace URI
7f561c08de6b Initial load
duke
parents:
diff changeset
  1186
   * (As defined in Namespaces, this is the declared URI which this node's
7f561c08de6b Initial load
duke
parents:
diff changeset
  1187
   * prefix -- or default in lieu thereof -- was mapped to.)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1188
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1189
   * <p>%REVIEW% Null or ""? -sb</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1190
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1191
   * @param nodeHandle the id of the node.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1192
   * @return String URI value of this node's namespace, or null if no
7f561c08de6b Initial load
duke
parents:
diff changeset
  1193
   * namespace was resolved.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1194
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1195
  public String getNamespaceURI(int nodeHandle)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1196
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1197
7f561c08de6b Initial load
duke
parents:
diff changeset
  1198
    return m_expandedNameTable.getNamespace(_exptype(makeNodeIdentity(nodeHandle)));
7f561c08de6b Initial load
duke
parents:
diff changeset
  1199
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1200
7f561c08de6b Initial load
duke
parents:
diff changeset
  1201
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1202
   * Get the string-value of a node as a String object
7f561c08de6b Initial load
duke
parents:
diff changeset
  1203
   * (see http://www.w3.org/TR/xpath#data-model
7f561c08de6b Initial load
duke
parents:
diff changeset
  1204
   * for the definition of a node's string-value).
7f561c08de6b Initial load
duke
parents:
diff changeset
  1205
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1206
   * @param nodeHandle The node ID.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1207
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1208
   * @return A string object that represents the string-value of the given node.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1209
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1210
  public XMLString getStringValue(int nodeHandle)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1211
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1212
    int identity = makeNodeIdentity(nodeHandle);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1213
    int type;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1214
    if(identity==DTM.NULL) // Separate lines because I wanted to breakpoint it
7f561c08de6b Initial load
duke
parents:
diff changeset
  1215
      type = DTM.NULL;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1216
    else
7f561c08de6b Initial load
duke
parents:
diff changeset
  1217
      type= _type(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1218
7f561c08de6b Initial load
duke
parents:
diff changeset
  1219
    if (isTextType(type))
7f561c08de6b Initial load
duke
parents:
diff changeset
  1220
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1221
      int dataIndex = _dataOrQName(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1222
      int offset = m_data.elementAt(dataIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1223
      int length = m_data.elementAt(dataIndex + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1224
7f561c08de6b Initial load
duke
parents:
diff changeset
  1225
      return m_xstrf.newstr(m_chars, offset, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1226
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1227
    else
7f561c08de6b Initial load
duke
parents:
diff changeset
  1228
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1229
      int firstChild = _firstch(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1230
7f561c08de6b Initial load
duke
parents:
diff changeset
  1231
      if (DTM.NULL != firstChild)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1232
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1233
        int offset = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1234
        int length = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1235
        int startNode = identity;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1236
7f561c08de6b Initial load
duke
parents:
diff changeset
  1237
        identity = firstChild;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1238
7f561c08de6b Initial load
duke
parents:
diff changeset
  1239
        do {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1240
          type = _type(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1241
7f561c08de6b Initial load
duke
parents:
diff changeset
  1242
          if (isTextType(type))
7f561c08de6b Initial load
duke
parents:
diff changeset
  1243
          {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1244
            int dataIndex = _dataOrQName(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1245
7f561c08de6b Initial load
duke
parents:
diff changeset
  1246
            if (-1 == offset)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1247
            {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1248
              offset = m_data.elementAt(dataIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1249
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1250
7f561c08de6b Initial load
duke
parents:
diff changeset
  1251
            length += m_data.elementAt(dataIndex + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1252
          }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1253
7f561c08de6b Initial load
duke
parents:
diff changeset
  1254
          identity = getNextNodeIdentity(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1255
        } while (DTM.NULL != identity && (_parent(identity) >= startNode));
7f561c08de6b Initial load
duke
parents:
diff changeset
  1256
7f561c08de6b Initial load
duke
parents:
diff changeset
  1257
        if (length > 0)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1258
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1259
          return m_xstrf.newstr(m_chars, offset, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1260
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1261
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1262
      else if(type != DTM.ELEMENT_NODE)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1263
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1264
        int dataIndex = _dataOrQName(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1265
7f561c08de6b Initial load
duke
parents:
diff changeset
  1266
        if (dataIndex < 0)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1267
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1268
          dataIndex = -dataIndex;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1269
          dataIndex = m_data.elementAt(dataIndex + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1270
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1271
        return m_xstrf.newstr(m_valuesOrPrefixes.indexToString(dataIndex));
7f561c08de6b Initial load
duke
parents:
diff changeset
  1272
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1273
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1274
7f561c08de6b Initial load
duke
parents:
diff changeset
  1275
    return m_xstrf.emptystr();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1276
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1277
7f561c08de6b Initial load
duke
parents:
diff changeset
  1278
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1279
   * Determine if the string-value of a node is whitespace
7f561c08de6b Initial load
duke
parents:
diff changeset
  1280
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1281
   * @param nodeHandle The node Handle.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1282
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1283
   * @return Return true if the given node is whitespace.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1284
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1285
  public boolean isWhitespace(int nodeHandle)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1286
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1287
    int identity = makeNodeIdentity(nodeHandle);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1288
    int type;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1289
    if(identity==DTM.NULL) // Separate lines because I wanted to breakpoint it
7f561c08de6b Initial load
duke
parents:
diff changeset
  1290
      type = DTM.NULL;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1291
    else
7f561c08de6b Initial load
duke
parents:
diff changeset
  1292
      type= _type(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1293
7f561c08de6b Initial load
duke
parents:
diff changeset
  1294
    if (isTextType(type))
7f561c08de6b Initial load
duke
parents:
diff changeset
  1295
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1296
      int dataIndex = _dataOrQName(identity);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1297
      int offset = m_data.elementAt(dataIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1298
      int length = m_data.elementAt(dataIndex + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1299
7f561c08de6b Initial load
duke
parents:
diff changeset
  1300
      return m_chars.isWhitespace(offset, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1301
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1302
    return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1303
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1304
7f561c08de6b Initial load
duke
parents:
diff changeset
  1305
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1306
   * Returns the <code>Element</code> whose <code>ID</code> is given by
7f561c08de6b Initial load
duke
parents:
diff changeset
  1307
   * <code>elementId</code>. If no such element exists, returns
7f561c08de6b Initial load
duke
parents:
diff changeset
  1308
   * <code>DTM.NULL</code>. Behavior is not defined if more than one element
7f561c08de6b Initial load
duke
parents:
diff changeset
  1309
   * has this <code>ID</code>. Attributes (including those
7f561c08de6b Initial load
duke
parents:
diff changeset
  1310
   * with the name "ID") are not of type ID unless so defined by DTD/Schema
7f561c08de6b Initial load
duke
parents:
diff changeset
  1311
   * information available to the DTM implementation.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1312
   * Implementations that do not know whether attributes are of type ID or
7f561c08de6b Initial load
duke
parents:
diff changeset
  1313
   * not are expected to return <code>DTM.NULL</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1314
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1315
   * <p>%REVIEW% Presumably IDs are still scoped to a single document,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1316
   * and this operation searches only within a single document, right?
7f561c08de6b Initial load
duke
parents:
diff changeset
  1317
   * Wouldn't want collisions between DTMs in the same process.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1318
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1319
   * @param elementId The unique <code>id</code> value for an element.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1320
   * @return The handle of the matching element.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1321
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1322
  public int getElementById(String elementId)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1323
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1324
7f561c08de6b Initial load
duke
parents:
diff changeset
  1325
    Integer intObj;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1326
    boolean isMore = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1327
7f561c08de6b Initial load
duke
parents:
diff changeset
  1328
    do
7f561c08de6b Initial load
duke
parents:
diff changeset
  1329
    {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
  1330
      intObj = m_idAttributes.get(elementId);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1331
7f561c08de6b Initial load
duke
parents:
diff changeset
  1332
      if (null != intObj)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1333
        return makeNodeHandle(intObj.intValue());
7f561c08de6b Initial load
duke
parents:
diff changeset
  1334
7f561c08de6b Initial load
duke
parents:
diff changeset
  1335
      if (!isMore || m_endDocumentOccured)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1336
        break;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1337
7f561c08de6b Initial load
duke
parents:
diff changeset
  1338
      isMore = nextNode();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1339
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1340
    while (null == intObj);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1341
7f561c08de6b Initial load
duke
parents:
diff changeset
  1342
    return DTM.NULL;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1343
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1344
7f561c08de6b Initial load
duke
parents:
diff changeset
  1345
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1346
   * Get a prefix either from the qname or from the uri mapping, or just make
7f561c08de6b Initial load
duke
parents:
diff changeset
  1347
   * one up!
7f561c08de6b Initial load
duke
parents:
diff changeset
  1348
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1349
   * @param qname The qualified name, which may be null.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1350
   * @param uri The namespace URI, which may be null.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1351
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1352
   * @return The prefix if there is one, or null.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1353
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1354
  public String getPrefix(String qname, String uri) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1355
    String prefix;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1356
    int uriIndex = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1357
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1358
    if (null != uri && uri.length() > 0) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1359
      do {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1360
        uriIndex = m_prefixMappings.indexOf(uri, ++uriIndex);
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1361
      } while ((uriIndex & 0x01) == 0);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1362
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1363
      if (uriIndex >= 0) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
  1364
        prefix = m_prefixMappings.get(uriIndex - 1);
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1365
      } else if (null != qname) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1366
        int indexOfNSSep = qname.indexOf(':');
7f561c08de6b Initial load
duke
parents:
diff changeset
  1367
7f561c08de6b Initial load
duke
parents:
diff changeset
  1368
        if (qname.equals("xmlns"))
7f561c08de6b Initial load
duke
parents:
diff changeset
  1369
          prefix = "";
7f561c08de6b Initial load
duke
parents:
diff changeset
  1370
        else if (qname.startsWith("xmlns:"))
7f561c08de6b Initial load
duke
parents:
diff changeset
  1371
          prefix = qname.substring(indexOfNSSep + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1372
        else
7f561c08de6b Initial load
duke
parents:
diff changeset
  1373
          prefix = (indexOfNSSep > 0)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1374
                   ? qname.substring(0, indexOfNSSep) : null;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1375
      } else {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1376
        prefix = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1377
      }
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1378
    } else if (null != qname) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1379
      int indexOfNSSep = qname.indexOf(':');
7f561c08de6b Initial load
duke
parents:
diff changeset
  1380
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1381
      if (indexOfNSSep > 0) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1382
        if (qname.startsWith("xmlns:"))
7f561c08de6b Initial load
duke
parents:
diff changeset
  1383
          prefix = qname.substring(indexOfNSSep + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1384
        else
7f561c08de6b Initial load
duke
parents:
diff changeset
  1385
          prefix = qname.substring(0, indexOfNSSep);
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1386
      } else {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1387
        if (qname.equals("xmlns"))
7f561c08de6b Initial load
duke
parents:
diff changeset
  1388
          prefix = "";
7f561c08de6b Initial load
duke
parents:
diff changeset
  1389
        else
7f561c08de6b Initial load
duke
parents:
diff changeset
  1390
          prefix = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1391
      }
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1392
    } else {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1393
      prefix = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1394
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1395
7f561c08de6b Initial load
duke
parents:
diff changeset
  1396
    return prefix;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1397
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1398
7f561c08de6b Initial load
duke
parents:
diff changeset
  1399
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1400
   * Get a prefix either from the uri mapping, or just make
7f561c08de6b Initial load
duke
parents:
diff changeset
  1401
   * one up!
7f561c08de6b Initial load
duke
parents:
diff changeset
  1402
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1403
   * @param uri The namespace URI, which may be null.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1404
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1405
   * @return The prefix if there is one, or null.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1406
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1407
  public int getIdForNamespace(String uri) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1408
     return m_valuesOrPrefixes.stringToIndex(uri);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1409
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1410
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1411
  /**
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1412
   * Get a prefix either from the qname or from the uri mapping, or just make
7f561c08de6b Initial load
duke
parents:
diff changeset
  1413
   * one up!
7f561c08de6b Initial load
duke
parents:
diff changeset
  1414
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1415
   * @return The prefix if there is one, or null.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1416
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1417
  public String getNamespaceURI(String prefix) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1418
    String uri = "";
7f561c08de6b Initial load
duke
parents:
diff changeset
  1419
    int prefixIndex = m_contextIndexes.peek() - 1 ;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1420
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1421
    if (null == prefix) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1422
      prefix = "";
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1423
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1424
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1425
    do {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1426
      prefixIndex = m_prefixMappings.indexOf(prefix, ++prefixIndex);
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1427
    } while ((prefixIndex >= 0) && (prefixIndex & 0x01) == 0x01);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1428
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1429
    if (prefixIndex > -1) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
  1430
      uri = m_prefixMappings.get(prefixIndex + 1);
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1431
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1432
7f561c08de6b Initial load
duke
parents:
diff changeset
  1433
    return uri;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1434
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1435
7f561c08de6b Initial load
duke
parents:
diff changeset
  1436
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1437
   * Set an ID string to node association in the ID table.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1438
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1439
   * @param id The ID string.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1440
   * @param elem The associated element handle.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1441
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1442
  public void setIDAttribute(String id, int elem)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1443
  {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
  1444
    m_idAttributes.put(id, elem);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1445
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1446
7f561c08de6b Initial load
duke
parents:
diff changeset
  1447
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1448
   * Check whether accumulated text should be stripped; if not,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1449
   * append the appropriate flavor of text/cdata node.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1450
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1451
  protected void charactersFlush()
7f561c08de6b Initial load
duke
parents:
diff changeset
  1452
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1453
7f561c08de6b Initial load
duke
parents:
diff changeset
  1454
    if (m_textPendingStart >= 0)  // -1 indicates no-text-in-progress
7f561c08de6b Initial load
duke
parents:
diff changeset
  1455
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1456
      int length = m_chars.size() - m_textPendingStart;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1457
      boolean doStrip = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1458
7f561c08de6b Initial load
duke
parents:
diff changeset
  1459
      if (getShouldStripWhitespace())
7f561c08de6b Initial load
duke
parents:
diff changeset
  1460
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1461
        doStrip = m_chars.isWhitespace(m_textPendingStart, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1462
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1463
7f561c08de6b Initial load
duke
parents:
diff changeset
  1464
      if (doStrip) {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1465
        m_chars.setLength(m_textPendingStart);  // Discard accumulated text
7f561c08de6b Initial load
duke
parents:
diff changeset
  1466
      } else {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1467
        // Guard against characters/ignorableWhitespace events that
7f561c08de6b Initial load
duke
parents:
diff changeset
  1468
        // contained no characters.  They should not result in a node.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1469
        if (length > 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1470
          int exName = m_expandedNameTable.getExpandedTypeID(DTM.TEXT_NODE);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1471
          int dataIndex = m_data.size();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1472
7f561c08de6b Initial load
duke
parents:
diff changeset
  1473
          m_previous = addNode(m_coalescedTextType, exName,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1474
                               m_parents.peek(), m_previous, dataIndex, false);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1475
7f561c08de6b Initial load
duke
parents:
diff changeset
  1476
          m_data.addElement(m_textPendingStart);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1477
          m_data.addElement(length);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1478
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1479
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1480
7f561c08de6b Initial load
duke
parents:
diff changeset
  1481
      // Reset for next text block
7f561c08de6b Initial load
duke
parents:
diff changeset
  1482
      m_textPendingStart = -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1483
      m_textType = m_coalescedTextType = DTM.TEXT_NODE;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1484
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1485
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1486
7f561c08de6b Initial load
duke
parents:
diff changeset
  1487
  ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
  1488
  // Implementation of the EntityResolver interface.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1489
  ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
  1490
7f561c08de6b Initial load
duke
parents:
diff changeset
  1491
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1492
   * Resolve an external entity.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1493
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1494
   * <p>Always return null, so that the parser will use the system
7f561c08de6b Initial load
duke
parents:
diff changeset
  1495
   * identifier provided in the XML document.  This method implements
7f561c08de6b Initial load
duke
parents:
diff changeset
  1496
   * the SAX default behaviour: application writers can override it
7f561c08de6b Initial load
duke
parents:
diff changeset
  1497
   * in a subclass to do special translations such as catalog lookups
7f561c08de6b Initial load
duke
parents:
diff changeset
  1498
   * or URI redirection.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1499
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1500
   * @param publicId The public identifer, or null if none is
7f561c08de6b Initial load
duke
parents:
diff changeset
  1501
   *                 available.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1502
   * @param systemId The system identifier provided in the XML
7f561c08de6b Initial load
duke
parents:
diff changeset
  1503
   *                 document.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1504
   * @return The new input source, or null to require the
7f561c08de6b Initial load
duke
parents:
diff changeset
  1505
   *         default behaviour.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1506
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  1507
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1508
   * @see EntityResolver#resolveEntity
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1509
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1510
   * @throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  1511
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1512
  public InputSource resolveEntity(String publicId, String systemId)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1513
          throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  1514
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1515
    return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1516
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1517
7f561c08de6b Initial load
duke
parents:
diff changeset
  1518
  ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
  1519
  // Implementation of DTDHandler interface.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1520
  ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
  1521
7f561c08de6b Initial load
duke
parents:
diff changeset
  1522
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1523
   * Receive notification of a notation declaration.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1524
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1525
   * <p>By default, do nothing.  Application writers may override this
7f561c08de6b Initial load
duke
parents:
diff changeset
  1526
   * method in a subclass if they wish to keep track of the notations
7f561c08de6b Initial load
duke
parents:
diff changeset
  1527
   * declared in a document.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1528
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1529
   * @param name The notation name.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1530
   * @param publicId The notation public identifier, or null if not
7f561c08de6b Initial load
duke
parents:
diff changeset
  1531
   *                 available.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1532
   * @param systemId The notation system identifier.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1533
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  1534
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1535
   * @see DTDHandler#notationDecl
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1536
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1537
   * @throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  1538
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1539
  public void notationDecl(String name, String publicId, String systemId)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1540
          throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  1541
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1542
7f561c08de6b Initial load
duke
parents:
diff changeset
  1543
    // no op
7f561c08de6b Initial load
duke
parents:
diff changeset
  1544
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1545
7f561c08de6b Initial load
duke
parents:
diff changeset
  1546
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1547
   * Receive notification of an unparsed entity declaration.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1548
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1549
   * <p>By default, do nothing.  Application writers may override this
7f561c08de6b Initial load
duke
parents:
diff changeset
  1550
   * method in a subclass to keep track of the unparsed entities
7f561c08de6b Initial load
duke
parents:
diff changeset
  1551
   * declared in a document.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1552
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1553
   * @param name The entity name.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1554
   * @param publicId The entity public identifier, or null if not
7f561c08de6b Initial load
duke
parents:
diff changeset
  1555
   *                 available.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1556
   * @param systemId The entity system identifier.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1557
   * @param notationName The name of the associated notation.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1558
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  1559
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1560
   * @see DTDHandler#unparsedEntityDecl
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1561
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1562
   * @throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  1563
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1564
  public void unparsedEntityDecl(String name, String publicId, String systemId,
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1565
                                 String notationName) throws SAXException
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1566
  {
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1567
    if (null == m_entities) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1568
      m_entities = new ArrayList<>();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1569
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1570
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1571
    try {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1572
      systemId = SystemIDResolver.getAbsoluteURI(systemId,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1573
                                                 getDocumentBaseURI());
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1574
    } catch (Exception e) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1575
      throw new SAXException(e);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1576
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1577
7f561c08de6b Initial load
duke
parents:
diff changeset
  1578
    //  private static final int ENTITY_FIELD_PUBLICID = 0;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1579
    m_entities.add(publicId);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1580
7f561c08de6b Initial load
duke
parents:
diff changeset
  1581
    //  private static final int ENTITY_FIELD_SYSTEMID = 1;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1582
    m_entities.add(systemId);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1583
7f561c08de6b Initial load
duke
parents:
diff changeset
  1584
    //  private static final int ENTITY_FIELD_NOTATIONNAME = 2;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1585
    m_entities.add(notationName);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1586
7f561c08de6b Initial load
duke
parents:
diff changeset
  1587
    //  private static final int ENTITY_FIELD_NAME = 3;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1588
    m_entities.add(name);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1589
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1590
7f561c08de6b Initial load
duke
parents:
diff changeset
  1591
  ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
  1592
  // Implementation of ContentHandler interface.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1593
  ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
  1594
7f561c08de6b Initial load
duke
parents:
diff changeset
  1595
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1596
   * Receive a Locator object for document events.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1597
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1598
   * <p>By default, do nothing.  Application writers may override this
7f561c08de6b Initial load
duke
parents:
diff changeset
  1599
   * method in a subclass if they wish to store the locator for use
7f561c08de6b Initial load
duke
parents:
diff changeset
  1600
   * with other document events.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1601
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1602
   * @param locator A locator for all SAX document events.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1603
   * @see ContentHandler#setDocumentLocator
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1604
   * @see Locator
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1605
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1606
  public void setDocumentLocator(Locator locator)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1607
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1608
    m_locator = locator;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1609
    m_systemId = locator.getSystemId();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1610
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1611
7f561c08de6b Initial load
duke
parents:
diff changeset
  1612
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1613
   * Receive notification of the beginning of the document.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1614
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1615
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  1616
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1617
   * @see ContentHandler#startDocument
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1618
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1619
  public void startDocument() throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  1620
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1621
    if (DEBUG)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1622
      System.out.println("startDocument");
7f561c08de6b Initial load
duke
parents:
diff changeset
  1623
7f561c08de6b Initial load
duke
parents:
diff changeset
  1624
7f561c08de6b Initial load
duke
parents:
diff changeset
  1625
    int doc = addNode(DTM.DOCUMENT_NODE,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1626
                      m_expandedNameTable.getExpandedTypeID(DTM.DOCUMENT_NODE),
7f561c08de6b Initial load
duke
parents:
diff changeset
  1627
                      DTM.NULL, DTM.NULL, 0, true);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1628
7f561c08de6b Initial load
duke
parents:
diff changeset
  1629
    m_parents.push(doc);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1630
    m_previous = DTM.NULL;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1631
7f561c08de6b Initial load
duke
parents:
diff changeset
  1632
    m_contextIndexes.push(m_prefixMappings.size());  // for the next element.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1633
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1634
7f561c08de6b Initial load
duke
parents:
diff changeset
  1635
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1636
   * Receive notification of the end of the document.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1637
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1638
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  1639
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1640
   * @see ContentHandler#endDocument
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1641
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1642
  public void endDocument() throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  1643
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1644
    if (DEBUG)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1645
      System.out.println("endDocument");
7f561c08de6b Initial load
duke
parents:
diff changeset
  1646
7f561c08de6b Initial load
duke
parents:
diff changeset
  1647
                charactersFlush();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1648
7f561c08de6b Initial load
duke
parents:
diff changeset
  1649
    m_nextsib.setElementAt(NULL,0);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1650
7f561c08de6b Initial load
duke
parents:
diff changeset
  1651
    if (m_firstch.elementAt(0) == NOTPROCESSED)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1652
      m_firstch.setElementAt(NULL,0);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1653
7f561c08de6b Initial load
duke
parents:
diff changeset
  1654
    if (DTM.NULL != m_previous)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1655
      m_nextsib.setElementAt(DTM.NULL,m_previous);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1656
7f561c08de6b Initial load
duke
parents:
diff changeset
  1657
    m_parents = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1658
    m_prefixMappings = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1659
    m_contextIndexes = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1660
7f561c08de6b Initial load
duke
parents:
diff changeset
  1661
    m_endDocumentOccured = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1662
7f561c08de6b Initial load
duke
parents:
diff changeset
  1663
    // Bugzilla 4858: throw away m_locator. we cache m_systemId
7f561c08de6b Initial load
duke
parents:
diff changeset
  1664
    m_locator = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1665
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1666
7f561c08de6b Initial load
duke
parents:
diff changeset
  1667
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1668
   * Receive notification of the start of a Namespace mapping.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1669
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1670
   * <p>By default, do nothing.  Application writers may override this
7f561c08de6b Initial load
duke
parents:
diff changeset
  1671
   * method in a subclass to take specific actions at the start of
7f561c08de6b Initial load
duke
parents:
diff changeset
  1672
   * each Namespace prefix scope (such as storing the prefix mapping).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1673
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1674
   * @param prefix The Namespace prefix being declared.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1675
   * @param uri The Namespace URI mapped to the prefix.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1676
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  1677
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1678
   * @see ContentHandler#startPrefixMapping
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1679
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1680
  public void startPrefixMapping(String prefix, String uri)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1681
          throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  1682
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1683
7f561c08de6b Initial load
duke
parents:
diff changeset
  1684
    if (DEBUG)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1685
      System.out.println("startPrefixMapping: prefix: " + prefix + ", uri: "
7f561c08de6b Initial load
duke
parents:
diff changeset
  1686
                         + uri);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1687
7f561c08de6b Initial load
duke
parents:
diff changeset
  1688
    if(null == prefix)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1689
      prefix = "";
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
  1690
    m_prefixMappings.add(prefix);
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
  1691
    m_prefixMappings.add(uri);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1692
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1693
7f561c08de6b Initial load
duke
parents:
diff changeset
  1694
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1695
   * Receive notification of the end of a Namespace mapping.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1696
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1697
   * <p>By default, do nothing.  Application writers may override this
7f561c08de6b Initial load
duke
parents:
diff changeset
  1698
   * method in a subclass to take specific actions at the end of
7f561c08de6b Initial load
duke
parents:
diff changeset
  1699
   * each prefix mapping.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1700
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1701
   * @param prefix The Namespace prefix being declared.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1702
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  1703
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1704
   * @see ContentHandler#endPrefixMapping
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1705
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1706
  public void endPrefixMapping(String prefix) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  1707
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1708
    if (DEBUG)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1709
      System.out.println("endPrefixMapping: prefix: " + prefix);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1710
7f561c08de6b Initial load
duke
parents:
diff changeset
  1711
    if(null == prefix)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1712
      prefix = "";
7f561c08de6b Initial load
duke
parents:
diff changeset
  1713
7f561c08de6b Initial load
duke
parents:
diff changeset
  1714
    int index = m_contextIndexes.peek() - 1;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1715
7f561c08de6b Initial load
duke
parents:
diff changeset
  1716
    do
7f561c08de6b Initial load
duke
parents:
diff changeset
  1717
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1718
      index = m_prefixMappings.indexOf(prefix, ++index);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1719
    } while ( (index >= 0) && ((index & 0x01) == 0x01) );
7f561c08de6b Initial load
duke
parents:
diff changeset
  1720
7f561c08de6b Initial load
duke
parents:
diff changeset
  1721
7f561c08de6b Initial load
duke
parents:
diff changeset
  1722
    if (index > -1)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1723
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1724
      m_prefixMappings.setElementAt("%@$#^@#", index);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1725
      m_prefixMappings.setElementAt("%@$#^@#", index + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1726
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1727
7f561c08de6b Initial load
duke
parents:
diff changeset
  1728
    // no op
7f561c08de6b Initial load
duke
parents:
diff changeset
  1729
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1730
7f561c08de6b Initial load
duke
parents:
diff changeset
  1731
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1732
   * Check if a declaration has already been made for a given prefix.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1733
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1734
   * @param prefix non-null prefix string.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1735
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1736
   * @return true if the declaration has already been declared in the
7f561c08de6b Initial load
duke
parents:
diff changeset
  1737
   *         current context.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1738
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1739
  protected boolean declAlreadyDeclared(String prefix) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1740
    int startDecls = m_contextIndexes.peek();
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1741
    Vector<String> prefixMappings = m_prefixMappings;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1742
    int nDecls = prefixMappings.size();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1743
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1744
    for (int i = startDecls; i < nDecls; i += 2) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
  1745
      String prefixDecl = prefixMappings.get(i);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1746
7f561c08de6b Initial load
duke
parents:
diff changeset
  1747
      if (prefixDecl == null)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1748
        continue;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1749
7f561c08de6b Initial load
duke
parents:
diff changeset
  1750
      if (prefixDecl.equals(prefix))
7f561c08de6b Initial load
duke
parents:
diff changeset
  1751
        return true;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1752
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1753
7f561c08de6b Initial load
duke
parents:
diff changeset
  1754
    return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1755
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1756
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1757
  boolean m_pastFirstElement=false;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1758
7f561c08de6b Initial load
duke
parents:
diff changeset
  1759
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1760
   * Receive notification of the start of an element.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1761
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1762
   * <p>By default, do nothing.  Application writers may override this
7f561c08de6b Initial load
duke
parents:
diff changeset
  1763
   * method in a subclass to take specific actions at the start of
7f561c08de6b Initial load
duke
parents:
diff changeset
  1764
   * each element (such as allocating a new tree node or writing
7f561c08de6b Initial load
duke
parents:
diff changeset
  1765
   * output to a file).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1766
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1767
   * @param uri The Namespace URI, or the empty string if the
7f561c08de6b Initial load
duke
parents:
diff changeset
  1768
   *        element has no Namespace URI or if Namespace
7f561c08de6b Initial load
duke
parents:
diff changeset
  1769
   *        processing is not being performed.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1770
   * @param localName The local name (without prefix), or the
7f561c08de6b Initial load
duke
parents:
diff changeset
  1771
   *        empty string if Namespace processing is not being
7f561c08de6b Initial load
duke
parents:
diff changeset
  1772
   *        performed.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1773
   * @param qName The qualified name (with prefix), or the
7f561c08de6b Initial load
duke
parents:
diff changeset
  1774
   *        empty string if qualified names are not available.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1775
   * @param attributes The specified or defaulted attributes.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1776
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  1777
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1778
   * @see ContentHandler#startElement
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1779
   */
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1780
  public void startElement(String uri, String localName, String qName,
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1781
                           Attributes attributes) throws SAXException
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1782
  {
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1783
    if (DEBUG) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1784
      System.out.println("startElement: uri: " + uri +
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1785
                         ", localname: " + localName +
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1786
                         ", qname: "+qName+", atts: " + attributes);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1787
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1788
      boolean DEBUG_ATTRS=true;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1789
      if (DEBUG_ATTRS & attributes!=null) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1790
        int n = attributes.getLength();
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1791
        if (n==0) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1792
          System.out.println("\tempty attribute list");
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1793
        } else for (int i = 0; i < n; i++) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1794
          System.out.println("\t attr: uri: " + attributes.getURI(i) +
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1795
                             ", localname: " + attributes.getLocalName(i) +
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1796
                             ", qname: " + attributes.getQName(i) +
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1797
                             ", type: " + attributes.getType(i) +
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1798
                             ", value: " + attributes.getValue(i));
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1799
        }
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1800
      }
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1801
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1802
7f561c08de6b Initial load
duke
parents:
diff changeset
  1803
    charactersFlush();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1804
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1805
    if ((localName == null || localName.isEmpty()) &&
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1806
        (uri == null || uri.isEmpty())) {
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1807
      localName = qName;
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1808
    }
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1809
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1810
    int exName = m_expandedNameTable.getExpandedTypeID(uri, localName, DTM.ELEMENT_NODE);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1811
    String prefix = getPrefix(qName, uri);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1812
    int prefixIndex = (null != prefix)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1813
                      ? m_valuesOrPrefixes.stringToIndex(qName) : 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1814
7f561c08de6b Initial load
duke
parents:
diff changeset
  1815
    int elemNode = addNode(DTM.ELEMENT_NODE, exName,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1816
                           m_parents.peek(), m_previous, prefixIndex, true);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1817
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1818
    if (m_indexing)
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1819
      indexNode(exName, elemNode);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1820
7f561c08de6b Initial load
duke
parents:
diff changeset
  1821
    m_parents.push(elemNode);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1822
7f561c08de6b Initial load
duke
parents:
diff changeset
  1823
    int startDecls = m_contextIndexes.peek();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1824
    int nDecls = m_prefixMappings.size();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1825
    int prev = DTM.NULL;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1826
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1827
    if (!m_pastFirstElement) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1828
      // SPECIAL CASE: Implied declaration at root element
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1829
      prefix = "xml";
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1830
      String declURL = "http://www.w3.org/XML/1998/namespace";
7f561c08de6b Initial load
duke
parents:
diff changeset
  1831
      exName = m_expandedNameTable.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1832
      int val = m_valuesOrPrefixes.stringToIndex(declURL);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1833
      prev = addNode(DTM.NAMESPACE_NODE, exName, elemNode,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1834
                     prev, val, false);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1835
      m_pastFirstElement=true;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1836
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1837
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1838
    for (int i = startDecls; i < nDecls; i += 2) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
  1839
      prefix = m_prefixMappings.get(i);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1840
7f561c08de6b Initial load
duke
parents:
diff changeset
  1841
      if (prefix == null)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1842
        continue;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1843
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
  1844
      String declURL = m_prefixMappings.get(i + 1);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1845
7f561c08de6b Initial load
duke
parents:
diff changeset
  1846
      exName = m_expandedNameTable.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1847
7f561c08de6b Initial load
duke
parents:
diff changeset
  1848
      int val = m_valuesOrPrefixes.stringToIndex(declURL);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1849
7f561c08de6b Initial load
duke
parents:
diff changeset
  1850
      prev = addNode(DTM.NAMESPACE_NODE, exName, elemNode,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1851
                     prev, val, false);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1852
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1853
7f561c08de6b Initial load
duke
parents:
diff changeset
  1854
    int n = attributes.getLength();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1855
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1856
    for (int i = 0; i < n; i++) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1857
      String attrUri = attributes.getURI(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1858
      String attrQName = attributes.getQName(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1859
      String valString = attributes.getValue(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1860
7f561c08de6b Initial load
duke
parents:
diff changeset
  1861
      prefix = getPrefix(attrQName, attrUri);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1862
7f561c08de6b Initial load
duke
parents:
diff changeset
  1863
      int nodeType;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1864
7f561c08de6b Initial load
duke
parents:
diff changeset
  1865
       String attrLocalName = attributes.getLocalName(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1866
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1867
      if ((null != attrQName) &&
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1868
          (attrQName.equals("xmlns") || attrQName.startsWith("xmlns:"))) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1869
        if (declAlreadyDeclared(prefix))
7f561c08de6b Initial load
duke
parents:
diff changeset
  1870
          continue;  // go to the next attribute.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1871
7f561c08de6b Initial load
duke
parents:
diff changeset
  1872
        nodeType = DTM.NAMESPACE_NODE;
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1873
      } else {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1874
        nodeType = DTM.ATTRIBUTE_NODE;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1875
7f561c08de6b Initial load
duke
parents:
diff changeset
  1876
        if (attributes.getType(i).equalsIgnoreCase("ID"))
7f561c08de6b Initial load
duke
parents:
diff changeset
  1877
          setIDAttribute(valString, elemNode);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1878
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1879
7f561c08de6b Initial load
duke
parents:
diff changeset
  1880
      // Bit of a hack... if somehow valString is null, stringToIndex will
7f561c08de6b Initial load
duke
parents:
diff changeset
  1881
      // return -1, which will make things very unhappy.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1882
      if (null == valString)
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1883
        valString = "";
7f561c08de6b Initial load
duke
parents:
diff changeset
  1884
7f561c08de6b Initial load
duke
parents:
diff changeset
  1885
      int val = m_valuesOrPrefixes.stringToIndex(valString);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1886
      //String attrLocalName = attributes.getLocalName(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1887
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1888
      if (null != prefix) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1889
        prefixIndex = m_valuesOrPrefixes.stringToIndex(attrQName);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1890
7f561c08de6b Initial load
duke
parents:
diff changeset
  1891
        int dataIndex = m_data.size();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1892
7f561c08de6b Initial load
duke
parents:
diff changeset
  1893
        m_data.addElement(prefixIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1894
        m_data.addElement(val);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1895
7f561c08de6b Initial load
duke
parents:
diff changeset
  1896
        val = -dataIndex;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1897
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1898
7f561c08de6b Initial load
duke
parents:
diff changeset
  1899
      exName = m_expandedNameTable.getExpandedTypeID(attrUri, attrLocalName, nodeType);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1900
      prev = addNode(nodeType, exName, elemNode, prev, val,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1901
                     false);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1902
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1903
7f561c08de6b Initial load
duke
parents:
diff changeset
  1904
    if (DTM.NULL != prev)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1905
      m_nextsib.setElementAt(DTM.NULL,prev);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1906
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1907
    if (null != m_wsfilter) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1908
      short wsv = m_wsfilter.getShouldStripSpace(makeNodeHandle(elemNode), this);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1909
      boolean shouldStrip = (DTMWSFilter.INHERIT == wsv)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1910
                            ? getShouldStripWhitespace()
7f561c08de6b Initial load
duke
parents:
diff changeset
  1911
                            : (DTMWSFilter.STRIP == wsv);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1912
7f561c08de6b Initial load
duke
parents:
diff changeset
  1913
      pushShouldStripWhitespace(shouldStrip);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1914
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1915
7f561c08de6b Initial load
duke
parents:
diff changeset
  1916
    m_previous = DTM.NULL;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1917
7f561c08de6b Initial load
duke
parents:
diff changeset
  1918
    m_contextIndexes.push(m_prefixMappings.size());  // for the children.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1919
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1920
7f561c08de6b Initial load
duke
parents:
diff changeset
  1921
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1922
   * Receive notification of the end of an element.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1923
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1924
   * <p>By default, do nothing.  Application writers may override this
7f561c08de6b Initial load
duke
parents:
diff changeset
  1925
   * method in a subclass to take specific actions at the end of
7f561c08de6b Initial load
duke
parents:
diff changeset
  1926
   * each element (such as finalising a tree node or writing
7f561c08de6b Initial load
duke
parents:
diff changeset
  1927
   * output to a file).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1928
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1929
   * @param uri The Namespace URI, or the empty string if the
7f561c08de6b Initial load
duke
parents:
diff changeset
  1930
   *        element has no Namespace URI or if Namespace
7f561c08de6b Initial load
duke
parents:
diff changeset
  1931
   *        processing is not being performed.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1932
   * @param localName The local name (without prefix), or the
7f561c08de6b Initial load
duke
parents:
diff changeset
  1933
   *        empty string if Namespace processing is not being
7f561c08de6b Initial load
duke
parents:
diff changeset
  1934
   *        performed.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1935
   * @param qName The qualified XML 1.0 name (with prefix), or the
7f561c08de6b Initial load
duke
parents:
diff changeset
  1936
   *        empty string if qualified names are not available.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1937
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  1938
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1939
   * @see ContentHandler#endElement
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1940
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1941
  public void endElement(String uri, String localName, String qName)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1942
          throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  1943
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1944
   if (DEBUG)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1945
      System.out.println("endElement: uri: " + uri + ", localname: "
7f561c08de6b Initial load
duke
parents:
diff changeset
  1946
                                                                                                 + localName + ", qname: "+qName);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1947
7f561c08de6b Initial load
duke
parents:
diff changeset
  1948
    charactersFlush();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1949
7f561c08de6b Initial load
duke
parents:
diff changeset
  1950
    // If no one noticed, startPrefixMapping is a drag.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1951
    // Pop the context for the last child (the one pushed by startElement)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1952
    m_contextIndexes.quickPop(1);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1953
7f561c08de6b Initial load
duke
parents:
diff changeset
  1954
    // Do it again for this one (the one pushed by the last endElement).
7f561c08de6b Initial load
duke
parents:
diff changeset
  1955
    int topContextIndex = m_contextIndexes.peek();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1956
    if (topContextIndex != m_prefixMappings.size()) {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1957
      m_prefixMappings.setSize(topContextIndex);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1958
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1959
7f561c08de6b Initial load
duke
parents:
diff changeset
  1960
    int lastNode = m_previous;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1961
7f561c08de6b Initial load
duke
parents:
diff changeset
  1962
    m_previous = m_parents.pop();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1963
7f561c08de6b Initial load
duke
parents:
diff changeset
  1964
    // If lastNode is still DTM.NULL, this element had no children
7f561c08de6b Initial load
duke
parents:
diff changeset
  1965
    if (DTM.NULL == lastNode)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1966
      m_firstch.setElementAt(DTM.NULL,m_previous);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1967
    else
7f561c08de6b Initial load
duke
parents:
diff changeset
  1968
      m_nextsib.setElementAt(DTM.NULL,lastNode);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1969
7f561c08de6b Initial load
duke
parents:
diff changeset
  1970
    popShouldStripWhitespace();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1971
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1972
7f561c08de6b Initial load
duke
parents:
diff changeset
  1973
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1974
   * Receive notification of character data inside an element.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1975
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1976
   * <p>By default, do nothing.  Application writers may override this
7f561c08de6b Initial load
duke
parents:
diff changeset
  1977
   * method to take specific actions for each chunk of character data
7f561c08de6b Initial load
duke
parents:
diff changeset
  1978
   * (such as adding the data to a node or buffer, or printing it to
7f561c08de6b Initial load
duke
parents:
diff changeset
  1979
   * a file).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1980
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1981
   * @param ch The characters.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1982
   * @param start The start position in the character array.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1983
   * @param length The number of characters to use from the
7f561c08de6b Initial load
duke
parents:
diff changeset
  1984
   *               character array.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1985
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  1986
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  1987
   * @see ContentHandler#characters
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1988
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1989
  public void characters(char ch[], int start, int length) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  1990
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1991
    if (m_textPendingStart == -1)  // First one in this block
7f561c08de6b Initial load
duke
parents:
diff changeset
  1992
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1993
      m_textPendingStart = m_chars.size();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1994
      m_coalescedTextType = m_textType;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1995
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1996
    // Type logic: If all adjacent text is CDATASections, the
7f561c08de6b Initial load
duke
parents:
diff changeset
  1997
    // concatentated text is treated as a single CDATASection (see
7f561c08de6b Initial load
duke
parents:
diff changeset
  1998
    // initialization above).  If any were ordinary Text, the whole
7f561c08de6b Initial load
duke
parents:
diff changeset
  1999
    // thing is treated as Text. This may be worth %REVIEW%ing.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2000
    else if (m_textType == DTM.TEXT_NODE)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2001
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2002
      m_coalescedTextType = DTM.TEXT_NODE;
7f561c08de6b Initial load
duke
parents:
diff changeset
  2003
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2004
7f561c08de6b Initial load
duke
parents:
diff changeset
  2005
    m_chars.append(ch, start, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
  2006
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2007
7f561c08de6b Initial load
duke
parents:
diff changeset
  2008
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2009
   * Receive notification of ignorable whitespace in element content.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2010
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2011
   * <p>By default, do nothing.  Application writers may override this
7f561c08de6b Initial load
duke
parents:
diff changeset
  2012
   * method to take specific actions for each chunk of ignorable
7f561c08de6b Initial load
duke
parents:
diff changeset
  2013
   * whitespace (such as adding data to a node or buffer, or printing
7f561c08de6b Initial load
duke
parents:
diff changeset
  2014
   * it to a file).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2015
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2016
   * @param ch The whitespace characters.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2017
   * @param start The start position in the character array.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2018
   * @param length The number of characters to use from the
7f561c08de6b Initial load
duke
parents:
diff changeset
  2019
   *               character array.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2020
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  2021
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2022
   * @see ContentHandler#ignorableWhitespace
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  2023
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2024
  public void ignorableWhitespace(char ch[], int start, int length)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2025
          throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2026
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2027
7f561c08de6b Initial load
duke
parents:
diff changeset
  2028
    // %OPT% We can probably take advantage of the fact that we know this
7f561c08de6b Initial load
duke
parents:
diff changeset
  2029
    // is whitespace.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2030
    characters(ch, start, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
  2031
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2032
7f561c08de6b Initial load
duke
parents:
diff changeset
  2033
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2034
   * Receive notification of a processing instruction.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2035
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2036
   * <p>By default, do nothing.  Application writers may override this
7f561c08de6b Initial load
duke
parents:
diff changeset
  2037
   * method in a subclass to take specific actions for each
7f561c08de6b Initial load
duke
parents:
diff changeset
  2038
   * processing instruction, such as setting status variables or
7f561c08de6b Initial load
duke
parents:
diff changeset
  2039
   * invoking other methods.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2040
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2041
   * @param target The processing instruction target.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2042
   * @param data The processing instruction data, or null if
7f561c08de6b Initial load
duke
parents:
diff changeset
  2043
   *             none is supplied.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2044
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  2045
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2046
   * @see ContentHandler#processingInstruction
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  2047
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2048
  public void processingInstruction(String target, String data)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2049
          throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2050
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2051
    if (DEBUG)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2052
                 System.out.println("processingInstruction: target: " + target +", data: "+data);
7f561c08de6b Initial load
duke
parents:
diff changeset
  2053
7f561c08de6b Initial load
duke
parents:
diff changeset
  2054
    charactersFlush();
7f561c08de6b Initial load
duke
parents:
diff changeset
  2055
7f561c08de6b Initial load
duke
parents:
diff changeset
  2056
    int exName = m_expandedNameTable.getExpandedTypeID(null, target,
7f561c08de6b Initial load
duke
parents:
diff changeset
  2057
                                         DTM.PROCESSING_INSTRUCTION_NODE);
7f561c08de6b Initial load
duke
parents:
diff changeset
  2058
    int dataIndex = m_valuesOrPrefixes.stringToIndex(data);
7f561c08de6b Initial load
duke
parents:
diff changeset
  2059
7f561c08de6b Initial load
duke
parents:
diff changeset
  2060
    m_previous = addNode(DTM.PROCESSING_INSTRUCTION_NODE, exName,
7f561c08de6b Initial load
duke
parents:
diff changeset
  2061
                         m_parents.peek(), m_previous,
7f561c08de6b Initial load
duke
parents:
diff changeset
  2062
                         dataIndex, false);
7f561c08de6b Initial load
duke
parents:
diff changeset
  2063
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2064
7f561c08de6b Initial load
duke
parents:
diff changeset
  2065
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2066
   * Receive notification of a skipped entity.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2067
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2068
   * <p>By default, do nothing.  Application writers may override this
7f561c08de6b Initial load
duke
parents:
diff changeset
  2069
   * method in a subclass to take specific actions for each
7f561c08de6b Initial load
duke
parents:
diff changeset
  2070
   * processing instruction, such as setting status variables or
7f561c08de6b Initial load
duke
parents:
diff changeset
  2071
   * invoking other methods.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2072
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2073
   * @param name The name of the skipped entity.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2074
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  2075
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2076
   * @see ContentHandler#processingInstruction
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  2077
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2078
  public void skippedEntity(String name) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2079
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2080
7f561c08de6b Initial load
duke
parents:
diff changeset
  2081
    // %REVIEW% What should be done here?
7f561c08de6b Initial load
duke
parents:
diff changeset
  2082
    // no op
7f561c08de6b Initial load
duke
parents:
diff changeset
  2083
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2084
7f561c08de6b Initial load
duke
parents:
diff changeset
  2085
  ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
  2086
  // Implementation of the ErrorHandler interface.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2087
  ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
  2088
7f561c08de6b Initial load
duke
parents:
diff changeset
  2089
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2090
   * Receive notification of a parser warning.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2091
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2092
   * <p>The default implementation does nothing.  Application writers
7f561c08de6b Initial load
duke
parents:
diff changeset
  2093
   * may override this method in a subclass to take specific actions
7f561c08de6b Initial load
duke
parents:
diff changeset
  2094
   * for each warning, such as inserting the message in a log file or
7f561c08de6b Initial load
duke
parents:
diff changeset
  2095
   * printing it to the console.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2096
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2097
   * @param e The warning information encoded as an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2098
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  2099
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2100
   * @see ErrorHandler#warning
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2101
   * @see SAXParseException
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  2102
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2103
  public void warning(SAXParseException e) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2104
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2105
7f561c08de6b Initial load
duke
parents:
diff changeset
  2106
    // %REVIEW% Is there anyway to get the JAXP error listener here?
7f561c08de6b Initial load
duke
parents:
diff changeset
  2107
    System.err.println(e.getMessage());
7f561c08de6b Initial load
duke
parents:
diff changeset
  2108
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2109
7f561c08de6b Initial load
duke
parents:
diff changeset
  2110
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2111
   * Receive notification of a recoverable parser error.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2112
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2113
   * <p>The default implementation does nothing.  Application writers
7f561c08de6b Initial load
duke
parents:
diff changeset
  2114
   * may override this method in a subclass to take specific actions
7f561c08de6b Initial load
duke
parents:
diff changeset
  2115
   * for each error, such as inserting the message in a log file or
7f561c08de6b Initial load
duke
parents:
diff changeset
  2116
   * printing it to the console.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2117
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2118
   * @param e The warning information encoded as an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2119
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  2120
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2121
   * @see ErrorHandler#warning
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2122
   * @see SAXParseException
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  2123
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2124
  public void error(SAXParseException e) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2125
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2126
    throw e;
7f561c08de6b Initial load
duke
parents:
diff changeset
  2127
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2128
7f561c08de6b Initial load
duke
parents:
diff changeset
  2129
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2130
   * Report a fatal XML parsing error.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2131
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2132
   * <p>The default implementation throws a SAXParseException.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2133
   * Application writers may override this method in a subclass if
7f561c08de6b Initial load
duke
parents:
diff changeset
  2134
   * they need to take specific actions for each fatal error (such as
7f561c08de6b Initial load
duke
parents:
diff changeset
  2135
   * collecting all of the errors into a single report): in any case,
7f561c08de6b Initial load
duke
parents:
diff changeset
  2136
   * the application must stop all regular processing when this
7f561c08de6b Initial load
duke
parents:
diff changeset
  2137
   * method is invoked, since the document is no longer reliable, and
7f561c08de6b Initial load
duke
parents:
diff changeset
  2138
   * the parser may no longer report parsing events.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2139
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2140
   * @param e The error information encoded as an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2141
   * @throws SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
  2142
   *            wrapping another exception.
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2143
   * @see ErrorHandler#fatalError
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2144
   * @see SAXParseException
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  2145
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2146
  public void fatalError(SAXParseException e) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2147
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2148
    throw e;
7f561c08de6b Initial load
duke
parents:
diff changeset
  2149
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2150
7f561c08de6b Initial load
duke
parents:
diff changeset
  2151
  ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
  2152
  // Implementation of the DeclHandler interface.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2153
  ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
  2154
7f561c08de6b Initial load
duke
parents:
diff changeset
  2155
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2156
   * Report an element type declaration.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2157
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2158
   * <p>The content model will consist of the string "EMPTY", the
7f561c08de6b Initial load
duke
parents:
diff changeset
  2159
   * string "ANY", or a parenthesised group, optionally followed
7f561c08de6b Initial load
duke
parents:
diff changeset
  2160
   * by an occurrence indicator.  The model will be normalized so
7f561c08de6b Initial load
duke
parents:
diff changeset
  2161
   * that all whitespace is removed,and will include the enclosing
7f561c08de6b Initial load
duke
parents:
diff changeset
  2162
   * parentheses.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2163
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2164
   * @param name The element type name.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2165
   * @param model The content model as a normalized string.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2166
   * @throws SAXException The application may raise an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2167
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2168
  public void elementDecl(String name, String model) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2169
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2170
7f561c08de6b Initial load
duke
parents:
diff changeset
  2171
    // no op
7f561c08de6b Initial load
duke
parents:
diff changeset
  2172
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2173
7f561c08de6b Initial load
duke
parents:
diff changeset
  2174
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2175
   * Report an attribute type declaration.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2176
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2177
   * <p>Only the effective (first) declaration for an attribute will
7f561c08de6b Initial load
duke
parents:
diff changeset
  2178
   * be reported.  The type will be one of the strings "CDATA",
7f561c08de6b Initial load
duke
parents:
diff changeset
  2179
   * "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",
7f561c08de6b Initial load
duke
parents:
diff changeset
  2180
   * "ENTITIES", or "NOTATION", or a parenthesized token group with
7f561c08de6b Initial load
duke
parents:
diff changeset
  2181
   * the separator "|" and all whitespace removed.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2182
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2183
   * @param eName The name of the associated element.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2184
   * @param aName The name of the attribute.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2185
   * @param type A string representing the attribute type.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2186
   * @param valueDefault A string representing the attribute default
7f561c08de6b Initial load
duke
parents:
diff changeset
  2187
   *        ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
7f561c08de6b Initial load
duke
parents:
diff changeset
  2188
   *        none of these applies.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2189
   * @param value A string representing the attribute's default value,
7f561c08de6b Initial load
duke
parents:
diff changeset
  2190
   *        or null if there is none.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2191
   * @throws SAXException The application may raise an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2192
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2193
  public void attributeDecl(
7f561c08de6b Initial load
duke
parents:
diff changeset
  2194
          String eName, String aName, String type, String valueDefault, String value)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2195
            throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2196
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2197
7f561c08de6b Initial load
duke
parents:
diff changeset
  2198
    // no op
7f561c08de6b Initial load
duke
parents:
diff changeset
  2199
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2200
7f561c08de6b Initial load
duke
parents:
diff changeset
  2201
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2202
   * Report an internal entity declaration.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2203
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2204
   * <p>Only the effective (first) declaration for each entity
7f561c08de6b Initial load
duke
parents:
diff changeset
  2205
   * will be reported.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2206
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2207
   * @param name The name of the entity.  If it is a parameter
7f561c08de6b Initial load
duke
parents:
diff changeset
  2208
   *        entity, the name will begin with '%'.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2209
   * @param value The replacement text of the entity.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2210
   * @throws SAXException The application may raise an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2211
   * @see #externalEntityDecl
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2212
   * @see DTDHandler#unparsedEntityDecl
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  2213
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2214
  public void internalEntityDecl(String name, String value)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2215
          throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2216
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2217
7f561c08de6b Initial load
duke
parents:
diff changeset
  2218
    // no op
7f561c08de6b Initial load
duke
parents:
diff changeset
  2219
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2220
7f561c08de6b Initial load
duke
parents:
diff changeset
  2221
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2222
   * Report a parsed external entity declaration.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2223
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2224
   * <p>Only the effective (first) declaration for each entity
7f561c08de6b Initial load
duke
parents:
diff changeset
  2225
   * will be reported.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2226
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2227
   * @param name The name of the entity.  If it is a parameter
7f561c08de6b Initial load
duke
parents:
diff changeset
  2228
   *        entity, the name will begin with '%'.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2229
   * @param publicId The declared public identifier of the entity, or
7f561c08de6b Initial load
duke
parents:
diff changeset
  2230
   *        null if none was declared.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2231
   * @param systemId The declared system identifier of the entity.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2232
   * @throws SAXException The application may raise an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2233
   * @see #internalEntityDecl
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2234
   * @see DTDHandler#unparsedEntityDecl
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  2235
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2236
  public void externalEntityDecl(
7f561c08de6b Initial load
duke
parents:
diff changeset
  2237
          String name, String publicId, String systemId) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2238
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2239
7f561c08de6b Initial load
duke
parents:
diff changeset
  2240
    // no op
7f561c08de6b Initial load
duke
parents:
diff changeset
  2241
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2242
7f561c08de6b Initial load
duke
parents:
diff changeset
  2243
  ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
  2244
  // Implementation of the LexicalHandler interface.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2245
  ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
  2246
7f561c08de6b Initial load
duke
parents:
diff changeset
  2247
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2248
   * Report the start of DTD declarations, if any.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2249
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2250
   * <p>Any declarations are assumed to be in the internal subset
7f561c08de6b Initial load
duke
parents:
diff changeset
  2251
   * unless otherwise indicated by a {@link #startEntity startEntity}
7f561c08de6b Initial load
duke
parents:
diff changeset
  2252
   * event.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2253
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2254
   * <p>Note that the start/endDTD events will appear within
7f561c08de6b Initial load
duke
parents:
diff changeset
  2255
   * the start/endDocument events from ContentHandler and
7f561c08de6b Initial load
duke
parents:
diff changeset
  2256
   * before the first startElement event.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2257
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2258
   * @param name The document type name.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2259
   * @param publicId The declared public identifier for the
7f561c08de6b Initial load
duke
parents:
diff changeset
  2260
   *        external DTD subset, or null if none was declared.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2261
   * @param systemId The declared system identifier for the
7f561c08de6b Initial load
duke
parents:
diff changeset
  2262
   *        external DTD subset, or null if none was declared.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2263
   * @throws SAXException The application may raise an
7f561c08de6b Initial load
duke
parents:
diff changeset
  2264
   *            exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2265
   * @see #endDTD
7f561c08de6b Initial load
duke
parents:
diff changeset
  2266
   * @see #startEntity
7f561c08de6b Initial load
duke
parents:
diff changeset
  2267
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2268
  public void startDTD(String name, String publicId, String systemId)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2269
          throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2270
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2271
7f561c08de6b Initial load
duke
parents:
diff changeset
  2272
    m_insideDTD = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
  2273
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2274
7f561c08de6b Initial load
duke
parents:
diff changeset
  2275
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2276
   * Report the end of DTD declarations.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2277
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2278
   * @throws SAXException The application may raise an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2279
   * @see #startDTD
7f561c08de6b Initial load
duke
parents:
diff changeset
  2280
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2281
  public void endDTD() throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2282
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2283
7f561c08de6b Initial load
duke
parents:
diff changeset
  2284
    m_insideDTD = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
  2285
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2286
7f561c08de6b Initial load
duke
parents:
diff changeset
  2287
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2288
   * Report the beginning of an entity in content.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2289
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2290
   * <p><strong>NOTE:</entity> entity references in attribute
7f561c08de6b Initial load
duke
parents:
diff changeset
  2291
   * values -- and the start and end of the document entity --
7f561c08de6b Initial load
duke
parents:
diff changeset
  2292
   * are never reported.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2293
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2294
   * <p>The start and end of the external DTD subset are reported
7f561c08de6b Initial load
duke
parents:
diff changeset
  2295
   * using the pseudo-name "[dtd]".  All other events must be
7f561c08de6b Initial load
duke
parents:
diff changeset
  2296
   * properly nested within start/end entity events.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2297
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2298
   * <p>Note that skipped entities will be reported through the
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2299
   * {@link ContentHandler#skippedEntity skippedEntity}
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  2300
   * event, which is part of the ContentHandler interface.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2301
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2302
   * @param name The name of the entity.  If it is a parameter
7f561c08de6b Initial load
duke
parents:
diff changeset
  2303
   *        entity, the name will begin with '%'.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2304
   * @throws SAXException The application may raise an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2305
   * @see #endEntity
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2306
   * @see DeclHandler#internalEntityDecl
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2307
   * @see DeclHandler#externalEntityDecl
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  2308
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2309
  public void startEntity(String name) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2310
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2311
7f561c08de6b Initial load
duke
parents:
diff changeset
  2312
    // no op
7f561c08de6b Initial load
duke
parents:
diff changeset
  2313
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2314
7f561c08de6b Initial load
duke
parents:
diff changeset
  2315
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2316
   * Report the end of an entity.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2317
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2318
   * @param name The name of the entity that is ending.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2319
   * @throws SAXException The application may raise an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2320
   * @see #startEntity
7f561c08de6b Initial load
duke
parents:
diff changeset
  2321
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2322
  public void endEntity(String name) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2323
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2324
7f561c08de6b Initial load
duke
parents:
diff changeset
  2325
    // no op
7f561c08de6b Initial load
duke
parents:
diff changeset
  2326
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2327
7f561c08de6b Initial load
duke
parents:
diff changeset
  2328
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2329
   * Report the start of a CDATA section.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2330
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2331
   * <p>The contents of the CDATA section will be reported through
43123
dd12865718f3 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input
clanger
parents: 33349
diff changeset
  2332
   * the regular {@link ContentHandler#characters
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  2333
   * characters} event.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2334
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2335
   * @throws SAXException The application may raise an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2336
   * @see #endCDATA
7f561c08de6b Initial load
duke
parents:
diff changeset
  2337
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2338
  public void startCDATA() throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2339
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2340
    m_textType = DTM.CDATA_SECTION_NODE;
7f561c08de6b Initial load
duke
parents:
diff changeset
  2341
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2342
7f561c08de6b Initial load
duke
parents:
diff changeset
  2343
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2344
   * Report the end of a CDATA section.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2345
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2346
   * @throws SAXException The application may raise an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2347
   * @see #startCDATA
7f561c08de6b Initial load
duke
parents:
diff changeset
  2348
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2349
  public void endCDATA() throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2350
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2351
    m_textType = DTM.TEXT_NODE;
7f561c08de6b Initial load
duke
parents:
diff changeset
  2352
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2353
7f561c08de6b Initial load
duke
parents:
diff changeset
  2354
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2355
   * Report an XML comment anywhere in the document.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2356
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2357
   * <p>This callback will be used for comments inside or outside the
7f561c08de6b Initial load
duke
parents:
diff changeset
  2358
   * document element, including comments in the external DTD
7f561c08de6b Initial load
duke
parents:
diff changeset
  2359
   * subset (if read).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
  2360
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2361
   * @param ch An array holding the characters in the comment.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2362
   * @param start The starting position in the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2363
   * @param length The number of characters to use from the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2364
   * @throws SAXException The application may raise an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2365
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2366
  public void comment(char ch[], int start, int length) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
  2367
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2368
7f561c08de6b Initial load
duke
parents:
diff changeset
  2369
    if (m_insideDTD)      // ignore comments if we're inside the DTD
7f561c08de6b Initial load
duke
parents:
diff changeset
  2370
      return;
7f561c08de6b Initial load
duke
parents:
diff changeset
  2371
7f561c08de6b Initial load
duke
parents:
diff changeset
  2372
    charactersFlush();
7f561c08de6b Initial load
duke
parents:
diff changeset
  2373
7f561c08de6b Initial load
duke
parents:
diff changeset
  2374
    int exName = m_expandedNameTable.getExpandedTypeID(DTM.COMMENT_NODE);
7f561c08de6b Initial load
duke
parents:
diff changeset
  2375
7f561c08de6b Initial load
duke
parents:
diff changeset
  2376
    // For now, treat comments as strings...  I guess we should do a
7f561c08de6b Initial load
duke
parents:
diff changeset
  2377
    // seperate FSB buffer instead.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2378
    int dataIndex = m_valuesOrPrefixes.stringToIndex(new String(ch, start,
7f561c08de6b Initial load
duke
parents:
diff changeset
  2379
                      length));
7f561c08de6b Initial load
duke
parents:
diff changeset
  2380
7f561c08de6b Initial load
duke
parents:
diff changeset
  2381
7f561c08de6b Initial load
duke
parents:
diff changeset
  2382
    m_previous = addNode(DTM.COMMENT_NODE, exName,
7f561c08de6b Initial load
duke
parents:
diff changeset
  2383
                         m_parents.peek(), m_previous, dataIndex, false);
7f561c08de6b Initial load
duke
parents:
diff changeset
  2384
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2385
7f561c08de6b Initial load
duke
parents:
diff changeset
  2386
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  2387
   * Set a run time property for this DTM instance.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2388
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2389
   * %REVIEW% Now that we no longer use this method to support
7f561c08de6b Initial load
duke
parents:
diff changeset
  2390
   * getSourceLocatorFor, can we remove it?
7f561c08de6b Initial load
duke
parents:
diff changeset
  2391
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2392
   * @param property a <code>String</code> value
7f561c08de6b Initial load
duke
parents:
diff changeset
  2393
   * @param value an <code>Object</code> value
7f561c08de6b Initial load
duke
parents:
diff changeset
  2394
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2395
  public void setProperty(String property, Object value)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2396
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2397
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2398
7f561c08de6b Initial load
duke
parents:
diff changeset
  2399
  /** Retrieve the SourceLocator associated with a specific node.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2400
   * This is only meaningful if the XalanProperties.SOURCE_LOCATION flag was
7f561c08de6b Initial load
duke
parents:
diff changeset
  2401
   * set True using setProperty; if it was never set, or was set false, we
7f561c08de6b Initial load
duke
parents:
diff changeset
  2402
   * will return null.
7f561c08de6b Initial load
duke
parents:
diff changeset
  2403
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
  2404
   * (We _could_ return a locator with the document's base URI and bogus
7f561c08de6b Initial load
duke
parents:
diff changeset
  2405
   * line/column information. Trying that; see the else clause.)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2406
   * */
7f561c08de6b Initial load
duke
parents:
diff changeset
  2407
  public SourceLocator getSourceLocatorFor(int node)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2408
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2409
    if (m_useSourceLocationProperty)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2410
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2411
7f561c08de6b Initial load
duke
parents:
diff changeset
  2412
      node = makeNodeIdentity(node);
7f561c08de6b Initial load
duke
parents:
diff changeset
  2413
7f561c08de6b Initial load
duke
parents:
diff changeset
  2414
7f561c08de6b Initial load
duke
parents:
diff changeset
  2415
      return new NodeLocator(null,
7f561c08de6b Initial load
duke
parents:
diff changeset
  2416
                             m_sourceSystemId.elementAt(node),
7f561c08de6b Initial load
duke
parents:
diff changeset
  2417
                             m_sourceLine.elementAt(node),
7f561c08de6b Initial load
duke
parents:
diff changeset
  2418
                             m_sourceColumn.elementAt(node));
7f561c08de6b Initial load
duke
parents:
diff changeset
  2419
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2420
    else if(m_locator!=null)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2421
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2422
        return new NodeLocator(null,m_locator.getSystemId(),-1,-1);
7f561c08de6b Initial load
duke
parents:
diff changeset
  2423
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2424
    else if(m_systemId!=null)
7f561c08de6b Initial load
duke
parents:
diff changeset
  2425
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
  2426
        return new NodeLocator(null,m_systemId,-1,-1);
7f561c08de6b Initial load
duke
parents:
diff changeset
  2427
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2428
    return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
  2429
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2430
7f561c08de6b Initial load
duke
parents:
diff changeset
  2431
  public String getFixedNames(int type){
7f561c08de6b Initial load
duke
parents:
diff changeset
  2432
    return m_fixednames[type];
7f561c08de6b Initial load
duke
parents:
diff changeset
  2433
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
  2434
}