jaxp/src/com/sun/org/apache/xml/internal/serializer/ToTextStream.java
author joehw
Thu, 07 Jun 2012 13:47:53 -0700
changeset 12902 0a840d92fa30
parent 12457 c348e06f0e82
permissions -rw-r--r--
7151118: Regressions on 7u4 b11 comp. 7u4 b06 on specjvm2008.xml.transform subbenchmark Summary: roll back XalanJ-2271 that caused the regression Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     6
 * Copyright 2001-2004 The Apache Software Foundation.
7f561c08de6b Initial load
duke
parents:
diff changeset
     7
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
     8
 * Licensed under the Apache License, Version 2.0 (the "License");
7f561c08de6b Initial load
duke
parents:
diff changeset
     9
 * you may not use this file except in compliance with the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    10
 * You may obtain a copy of the License at
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *     http://www.apache.org/licenses/LICENSE-2.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
 * $Id: ToTextStream.java,v 1.2.4.1 2005/09/21 10:35:34 pvedula Exp $
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
package com.sun.org.apache.xml.internal.serializer;
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import java.io.IOException;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import com.sun.org.apache.xml.internal.serializer.utils.Utils;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
import org.xml.sax.Attributes;
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
import org.xml.sax.SAXException;
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
 * This class is not a public API.
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
 * It is only public because it is used in other packages.
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 * This class converts SAX or SAX-like calls to a
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
 * serialized document for xsl:output method of "text".
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
 * @xsl.usage internal
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
public final class ToTextStream extends ToStream
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
{
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
   * Default constructor.
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
  public ToTextStream()
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
    super();
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
   * Receive notification of the beginning of a document.
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
   * <p>The SAX parser will invoke this method only once, before any
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
   * other methods in this interface or in DTDHandler (except for
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
   * setDocumentLocator).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
   * @throws org.xml.sax.SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
   *            wrapping another exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
   * @throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
  protected void startDocumentInternal() throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
    super.startDocumentInternal();
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
    m_needToCallStartDocument = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
    // No action for the moment.
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
   * Receive notification of the end of a document.
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
   * <p>The SAX parser will invoke this method only once, and it will
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
   * be the last method invoked during the parse.  The parser shall
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
   * not invoke this method until it has either abandoned parsing
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
   * (because of an unrecoverable error) or reached the end of
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
   * input.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
   * @throws org.xml.sax.SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
   *            wrapping another exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
   * @throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
  public void endDocument() throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
    flushPending();
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
    flushWriter();
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
    if (m_tracer != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
        super.fireEndDoc();
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
   * Receive notification of the beginning of an element.
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
   * <p>The Parser will invoke this method at the beginning of every
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
   * element in the XML document; there will be a corresponding
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
   * endElement() event for every startElement() event (even when the
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
   * element is empty). All of the element's content will be
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
   * reported, in order, before the corresponding endElement()
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
   * event.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
   * <p>If the element name has a namespace prefix, the prefix will
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
   * still be attached.  Note that the attribute list provided will
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
   * contain only attributes with explicit values (specified or
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
   * defaulted): #IMPLIED attributes will be omitted.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
   * @param namespaceURI The Namespace URI, or the empty string if the
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
   *        element has no Namespace URI or if Namespace
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
   *        processing is not being performed.
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
   * @param localName The local name (without prefix), or the
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
   *        empty string if Namespace processing is not being
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
   *        performed.
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
   * @param name The qualified name (with prefix), or the
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
   *        empty string if qualified names are not available.
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
   * @param atts The attributes attached to the element, if any.
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
   * @throws org.xml.sax.SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
   *            wrapping another exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
   * @see #endElement
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
   * @see org.xml.sax.AttributeList
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
   * @throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
  public void startElement(
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
          String namespaceURI, String localName, String name, Attributes atts)
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
            throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
    // time to fire off startElement event
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
    if (m_tracer != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
        super.fireStartElem(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
        this.firePseudoAttributes();
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
    return;
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
   * Receive notification of the end of an element.
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
   * <p>The SAX parser will invoke this method at the end of every
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
   * element in the XML document; there will be a corresponding
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
   * startElement() event for every endElement() event (even when the
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
   * element is empty).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
   * <p>If the element name has a namespace prefix, the prefix will
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
   * still be attached to the name.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
   * @param namespaceURI The Namespace URI, or the empty string if the
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
   *        element has no Namespace URI or if Namespace
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
   *        processing is not being performed.
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
   * @param localName The local name (without prefix), or the
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
   *        empty string if Namespace processing is not being
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
   *        performed.
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
   * @param name The qualified name (with prefix), or the
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
   *        empty string if qualified names are not available.
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
   * @throws org.xml.sax.SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
   *            wrapping another exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
   * @throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
  public void endElement(String namespaceURI, String localName, String name)
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
          throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
        if (m_tracer != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
            super.fireEndElem(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
   * Receive notification of character data.
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
   * <p>The Parser will call this method to report each chunk of
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
   * character data.  SAX parsers may return all contiguous character
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
   * data in a single chunk, or they may split it into several
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
   * chunks; however, all of the characters in any single event
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
   * must come from the same external entity, so that the Locator
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
   * provides useful information.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
   * <p>The application must not attempt to read from the array
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
   * outside of the specified range.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
   * <p>Note that some parsers will report whitespace using the
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
   * ignorableWhitespace() method rather than this one (validating
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
   * parsers must do so).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
   * @param ch The characters from the XML document.
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
   * @param start The start position in the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
   * @param length The number of characters to read from the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
   * @throws org.xml.sax.SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
   *            wrapping another exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
   * @see #ignorableWhitespace
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
   * @see org.xml.sax.Locator
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
  public void characters(char ch[], int start, int length)
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
          throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
    flushPending();
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
    try
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
        if (inTemporaryOutputState()) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
            /* leave characters un-processed as we are
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
             * creating temporary output, the output generated by
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
             * this serializer will be input to a final serializer
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
             * later on and it will do the processing in final
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
             * output state (not temporary output state).
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
             *
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
             * A "temporary" ToTextStream serializer is used to
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
             * evaluate attribute value templates (for example),
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
             * and the result of evaluating such a thing
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
             * is fed into a final serializer later on.
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
             */
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
            m_writer.write(ch, start, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
        else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
            // In final output state we do process the characters!
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
            writeNormalizedChars(ch, start, length, m_lineSepUse);
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
        if (m_tracer != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
            super.fireCharEvent(ch, start, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
    catch(IOException ioe)
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
      throw new SAXException(ioe);
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
   * If available, when the disable-output-escaping attribute is used,
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
   * output raw text without escaping.
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
   * @param ch The characters from the XML document.
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
   * @param start The start position in the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
   * @param length The number of characters to read from the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
   * @throws org.xml.sax.SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
   *            wrapping another exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
  public void charactersRaw(char ch[], int start, int length)
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
          throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
    try
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
      writeNormalizedChars(ch, start, length, m_lineSepUse);
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
    catch(IOException ioe)
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
      throw new SAXException(ioe);
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
7f561c08de6b Initial load
duke
parents:
diff changeset
   258
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
     * Normalize the characters, but don't escape.  Different from
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
     * SerializerToXML#writeNormalizedChars because it does not attempt to do
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
     * XML escaping at all.
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
     * @param ch The characters from the XML document.
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
     * @param start The start position in the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
     * @param length The number of characters to read from the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   266
     * @param useLineSep true if the operating systems
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
     * end-of-line separator should be output rather than a new-line character.
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   269
     * @throws IOException
7f561c08de6b Initial load
duke
parents:
diff changeset
   270
     * @throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   272
    void writeNormalizedChars(
7f561c08de6b Initial load
duke
parents:
diff changeset
   273
        final char ch[],
7f561c08de6b Initial load
duke
parents:
diff changeset
   274
            final int start,
7f561c08de6b Initial load
duke
parents:
diff changeset
   275
            final int length,
7f561c08de6b Initial load
duke
parents:
diff changeset
   276
            final boolean useLineSep)
7f561c08de6b Initial load
duke
parents:
diff changeset
   277
            throws IOException, org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   278
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   279
        final String encoding = getEncoding();
7f561c08de6b Initial load
duke
parents:
diff changeset
   280
        final java.io.Writer writer = m_writer;
7f561c08de6b Initial load
duke
parents:
diff changeset
   281
        final int end = start + length;
7f561c08de6b Initial load
duke
parents:
diff changeset
   282
7f561c08de6b Initial load
duke
parents:
diff changeset
   283
        /* copy a few "constants" before the loop for performance */
7f561c08de6b Initial load
duke
parents:
diff changeset
   284
        final char S_LINEFEED = CharInfo.S_LINEFEED;
7f561c08de6b Initial load
duke
parents:
diff changeset
   285
7f561c08de6b Initial load
duke
parents:
diff changeset
   286
        // This for() loop always increments i by one at the end
7f561c08de6b Initial load
duke
parents:
diff changeset
   287
        // of the loop.  Additional increments of i adjust for when
7f561c08de6b Initial load
duke
parents:
diff changeset
   288
        // two input characters (a high/low UTF16 surrogate pair)
7f561c08de6b Initial load
duke
parents:
diff changeset
   289
        // are processed.
7f561c08de6b Initial load
duke
parents:
diff changeset
   290
        for (int i = start; i < end; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   291
            final char c = ch[i];
7f561c08de6b Initial load
duke
parents:
diff changeset
   292
7f561c08de6b Initial load
duke
parents:
diff changeset
   293
            if (S_LINEFEED == c && useLineSep) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   294
                writer.write(m_lineSep, 0, m_lineSepLen);
7f561c08de6b Initial load
duke
parents:
diff changeset
   295
                // one input char processed
7f561c08de6b Initial load
duke
parents:
diff changeset
   296
            } else if (m_encodingInfo.isInEncoding(c)) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   297
                writer.write(c);
7f561c08de6b Initial load
duke
parents:
diff changeset
   298
                // one input char processed
7f561c08de6b Initial load
duke
parents:
diff changeset
   299
            } else if (Encodings.isHighUTF16Surrogate(c)) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   300
                final int codePoint = writeUTF16Surrogate(c, ch, i, end);
7f561c08de6b Initial load
duke
parents:
diff changeset
   301
                if (codePoint != 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   302
                    // I think we can just emit the message,
7f561c08de6b Initial load
duke
parents:
diff changeset
   303
                    // not crash and burn.
7f561c08de6b Initial load
duke
parents:
diff changeset
   304
                    final String integralValue = Integer.toString(codePoint);
7f561c08de6b Initial load
duke
parents:
diff changeset
   305
                    final String msg = Utils.messages.createMessage(
7f561c08de6b Initial load
duke
parents:
diff changeset
   306
                        MsgKey.ER_ILLEGAL_CHARACTER,
7f561c08de6b Initial load
duke
parents:
diff changeset
   307
                        new Object[] { integralValue, encoding });
7f561c08de6b Initial load
duke
parents:
diff changeset
   308
7f561c08de6b Initial load
duke
parents:
diff changeset
   309
                    //Older behavior was to throw the message,
7f561c08de6b Initial load
duke
parents:
diff changeset
   310
                    //but newer gentler behavior is to write a message to System.err
7f561c08de6b Initial load
duke
parents:
diff changeset
   311
                    //throw new SAXException(msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   312
                    System.err.println(msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   313
7f561c08de6b Initial load
duke
parents:
diff changeset
   314
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   315
                i++; // two input chars processed
7f561c08de6b Initial load
duke
parents:
diff changeset
   316
            } else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   317
                // Don't know what to do with this char, it is
7f561c08de6b Initial load
duke
parents:
diff changeset
   318
                // not in the encoding and not a high char in
7f561c08de6b Initial load
duke
parents:
diff changeset
   319
                // a surrogate pair, so write out as an entity ref
7f561c08de6b Initial load
duke
parents:
diff changeset
   320
                if (encoding != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   321
                    /* The output encoding is known,
7f561c08de6b Initial load
duke
parents:
diff changeset
   322
                     * so somthing is wrong.
7f561c08de6b Initial load
duke
parents:
diff changeset
   323
                     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   324
7f561c08de6b Initial load
duke
parents:
diff changeset
   325
                    // not in the encoding, so write out a character reference
7f561c08de6b Initial load
duke
parents:
diff changeset
   326
                    writer.write('&');
7f561c08de6b Initial load
duke
parents:
diff changeset
   327
                    writer.write('#');
7f561c08de6b Initial load
duke
parents:
diff changeset
   328
                    writer.write(Integer.toString(c));
7f561c08de6b Initial load
duke
parents:
diff changeset
   329
                    writer.write(';');
7f561c08de6b Initial load
duke
parents:
diff changeset
   330
7f561c08de6b Initial load
duke
parents:
diff changeset
   331
                    // I think we can just emit the message,
7f561c08de6b Initial load
duke
parents:
diff changeset
   332
                    // not crash and burn.
7f561c08de6b Initial load
duke
parents:
diff changeset
   333
                    final String integralValue = Integer.toString(c);
7f561c08de6b Initial load
duke
parents:
diff changeset
   334
                    final String msg = Utils.messages.createMessage(
7f561c08de6b Initial load
duke
parents:
diff changeset
   335
                        MsgKey.ER_ILLEGAL_CHARACTER,
7f561c08de6b Initial load
duke
parents:
diff changeset
   336
                        new Object[] { integralValue, encoding });
7f561c08de6b Initial load
duke
parents:
diff changeset
   337
7f561c08de6b Initial load
duke
parents:
diff changeset
   338
                    //Older behavior was to throw the message,
7f561c08de6b Initial load
duke
parents:
diff changeset
   339
                    //but newer gentler behavior is to write a message to System.err
7f561c08de6b Initial load
duke
parents:
diff changeset
   340
                    //throw new SAXException(msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   341
                    System.err.println(msg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   342
                } else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   343
                    /* The output encoding is not known,
7f561c08de6b Initial load
duke
parents:
diff changeset
   344
                     * so just write it out as-is.
7f561c08de6b Initial load
duke
parents:
diff changeset
   345
                     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   346
                    writer.write(c);
7f561c08de6b Initial load
duke
parents:
diff changeset
   347
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   348
7f561c08de6b Initial load
duke
parents:
diff changeset
   349
                // one input char was processed
7f561c08de6b Initial load
duke
parents:
diff changeset
   350
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   351
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   352
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   353
7f561c08de6b Initial load
duke
parents:
diff changeset
   354
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   355
   * Receive notification of cdata.
7f561c08de6b Initial load
duke
parents:
diff changeset
   356
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   357
   * <p>The Parser will call this method to report each chunk of
7f561c08de6b Initial load
duke
parents:
diff changeset
   358
   * character data.  SAX parsers may return all contiguous character
7f561c08de6b Initial load
duke
parents:
diff changeset
   359
   * data in a single chunk, or they may split it into several
7f561c08de6b Initial load
duke
parents:
diff changeset
   360
   * chunks; however, all of the characters in any single event
7f561c08de6b Initial load
duke
parents:
diff changeset
   361
   * must come from the same external entity, so that the Locator
7f561c08de6b Initial load
duke
parents:
diff changeset
   362
   * provides useful information.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   363
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   364
   * <p>The application must not attempt to read from the array
7f561c08de6b Initial load
duke
parents:
diff changeset
   365
   * outside of the specified range.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   366
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   367
   * <p>Note that some parsers will report whitespace using the
7f561c08de6b Initial load
duke
parents:
diff changeset
   368
   * ignorableWhitespace() method rather than this one (validating
7f561c08de6b Initial load
duke
parents:
diff changeset
   369
   * parsers must do so).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   370
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   371
   * @param ch The characters from the XML document.
7f561c08de6b Initial load
duke
parents:
diff changeset
   372
   * @param start The start position in the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   373
   * @param length The number of characters to read from the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   374
   * @throws org.xml.sax.SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
   375
   *            wrapping another exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   376
   * @see #ignorableWhitespace
7f561c08de6b Initial load
duke
parents:
diff changeset
   377
   * @see org.xml.sax.Locator
7f561c08de6b Initial load
duke
parents:
diff changeset
   378
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   379
  public void cdata(char ch[], int start, int length)
7f561c08de6b Initial load
duke
parents:
diff changeset
   380
          throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   381
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   382
    try
7f561c08de6b Initial load
duke
parents:
diff changeset
   383
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   384
        writeNormalizedChars(ch, start, length, m_lineSepUse);
7f561c08de6b Initial load
duke
parents:
diff changeset
   385
        if (m_tracer != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   386
            super.fireCDATAEvent(ch, start, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   387
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   388
    catch(IOException ioe)
7f561c08de6b Initial load
duke
parents:
diff changeset
   389
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   390
      throw new SAXException(ioe);
7f561c08de6b Initial load
duke
parents:
diff changeset
   391
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   392
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   393
7f561c08de6b Initial load
duke
parents:
diff changeset
   394
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   395
   * Receive notification of ignorable whitespace in element content.
7f561c08de6b Initial load
duke
parents:
diff changeset
   396
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   397
   * <p>Validating Parsers must use this method to report each chunk
7f561c08de6b Initial load
duke
parents:
diff changeset
   398
   * of ignorable whitespace (see the W3C XML 1.0 recommendation,
7f561c08de6b Initial load
duke
parents:
diff changeset
   399
   * section 2.10): non-validating parsers may also use this method
7f561c08de6b Initial load
duke
parents:
diff changeset
   400
   * if they are capable of parsing and using content models.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   401
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   402
   * <p>SAX parsers may return all contiguous whitespace in a single
7f561c08de6b Initial load
duke
parents:
diff changeset
   403
   * chunk, or they may split it into several chunks; however, all of
7f561c08de6b Initial load
duke
parents:
diff changeset
   404
   * the characters in any single event must come from the same
7f561c08de6b Initial load
duke
parents:
diff changeset
   405
   * external entity, so that the Locator provides useful
7f561c08de6b Initial load
duke
parents:
diff changeset
   406
   * information.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   407
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   408
   * <p>The application must not attempt to read from the array
7f561c08de6b Initial load
duke
parents:
diff changeset
   409
   * outside of the specified range.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   410
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   411
   * @param ch The characters from the XML document.
7f561c08de6b Initial load
duke
parents:
diff changeset
   412
   * @param start The start position in the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   413
   * @param length The number of characters to read from the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   414
   * @throws org.xml.sax.SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
   415
   *            wrapping another exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   416
   * @see #characters
7f561c08de6b Initial load
duke
parents:
diff changeset
   417
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   418
   * @throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   419
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   420
  public void ignorableWhitespace(char ch[], int start, int length)
7f561c08de6b Initial load
duke
parents:
diff changeset
   421
          throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   422
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   423
7f561c08de6b Initial load
duke
parents:
diff changeset
   424
    try
7f561c08de6b Initial load
duke
parents:
diff changeset
   425
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   426
      writeNormalizedChars(ch, start, length, m_lineSepUse);
7f561c08de6b Initial load
duke
parents:
diff changeset
   427
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   428
    catch(IOException ioe)
7f561c08de6b Initial load
duke
parents:
diff changeset
   429
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   430
      throw new SAXException(ioe);
7f561c08de6b Initial load
duke
parents:
diff changeset
   431
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   432
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   433
7f561c08de6b Initial load
duke
parents:
diff changeset
   434
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   435
   * Receive notification of a processing instruction.
7f561c08de6b Initial load
duke
parents:
diff changeset
   436
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   437
   * <p>The Parser will invoke this method once for each processing
7f561c08de6b Initial load
duke
parents:
diff changeset
   438
   * instruction found: note that processing instructions may occur
7f561c08de6b Initial load
duke
parents:
diff changeset
   439
   * before or after the main document element.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   440
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   441
   * <p>A SAX parser should never report an XML declaration (XML 1.0,
7f561c08de6b Initial load
duke
parents:
diff changeset
   442
   * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
7f561c08de6b Initial load
duke
parents:
diff changeset
   443
   * using this method.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   444
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   445
   * @param target The processing instruction target.
7f561c08de6b Initial load
duke
parents:
diff changeset
   446
   * @param data The processing instruction data, or null if
7f561c08de6b Initial load
duke
parents:
diff changeset
   447
   *        none was supplied.
7f561c08de6b Initial load
duke
parents:
diff changeset
   448
   * @throws org.xml.sax.SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
   449
   *            wrapping another exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   450
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   451
   * @throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   452
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   453
  public void processingInstruction(String target, String data)
7f561c08de6b Initial load
duke
parents:
diff changeset
   454
          throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   455
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   456
    // flush anything pending first
7f561c08de6b Initial load
duke
parents:
diff changeset
   457
    flushPending();
7f561c08de6b Initial load
duke
parents:
diff changeset
   458
7f561c08de6b Initial load
duke
parents:
diff changeset
   459
    if (m_tracer != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   460
        super.fireEscapingEvent(target, data);
7f561c08de6b Initial load
duke
parents:
diff changeset
   461
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   462
7f561c08de6b Initial load
duke
parents:
diff changeset
   463
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   464
   * Called when a Comment is to be constructed.
7f561c08de6b Initial load
duke
parents:
diff changeset
   465
   * Note that Xalan will normally invoke the other version of this method.
7f561c08de6b Initial load
duke
parents:
diff changeset
   466
   * %REVIEW% In fact, is this one ever needed, or was it a mistake?
7f561c08de6b Initial load
duke
parents:
diff changeset
   467
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   468
   * @param   data  The comment data.
7f561c08de6b Initial load
duke
parents:
diff changeset
   469
   * @throws org.xml.sax.SAXException Any SAX exception, possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
   470
   *            wrapping another exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   471
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   472
  public void comment(String data) throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   473
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   474
      final int length = data.length();
7f561c08de6b Initial load
duke
parents:
diff changeset
   475
      if (length > m_charsBuff.length)
7f561c08de6b Initial load
duke
parents:
diff changeset
   476
      {
7f561c08de6b Initial load
duke
parents:
diff changeset
   477
          m_charsBuff = new char[length*2 + 1];
7f561c08de6b Initial load
duke
parents:
diff changeset
   478
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   479
      data.getChars(0, length, m_charsBuff, 0);
7f561c08de6b Initial load
duke
parents:
diff changeset
   480
      comment(m_charsBuff, 0, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   481
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   482
7f561c08de6b Initial load
duke
parents:
diff changeset
   483
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   484
   * Report an XML comment anywhere in the document.
7f561c08de6b Initial load
duke
parents:
diff changeset
   485
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   486
   * This callback will be used for comments inside or outside the
7f561c08de6b Initial load
duke
parents:
diff changeset
   487
   * document element, including comments in the external DTD
7f561c08de6b Initial load
duke
parents:
diff changeset
   488
   * subset (if read).
7f561c08de6b Initial load
duke
parents:
diff changeset
   489
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   490
   * @param ch An array holding the characters in the comment.
7f561c08de6b Initial load
duke
parents:
diff changeset
   491
   * @param start The starting position in the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   492
   * @param length The number of characters to use from the array.
7f561c08de6b Initial load
duke
parents:
diff changeset
   493
   * @throws org.xml.sax.SAXException The application may raise an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   494
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   495
  public void comment(char ch[], int start, int length)
7f561c08de6b Initial load
duke
parents:
diff changeset
   496
          throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   497
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   498
7f561c08de6b Initial load
duke
parents:
diff changeset
   499
    flushPending();
7f561c08de6b Initial load
duke
parents:
diff changeset
   500
    if (m_tracer != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   501
        super.fireCommentEvent(ch, start, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   502
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   503
7f561c08de6b Initial load
duke
parents:
diff changeset
   504
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   505
   * Receive notivication of a entityReference.
7f561c08de6b Initial load
duke
parents:
diff changeset
   506
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   507
   * @param name non-null reference to the name of the entity.
7f561c08de6b Initial load
duke
parents:
diff changeset
   508
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   509
   * @throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   510
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   511
  public void entityReference(String name) throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   512
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   513
        if (m_tracer != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   514
            super.fireEntityReference(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   515
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   516
7f561c08de6b Initial load
duke
parents:
diff changeset
   517
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   518
     * @see ExtendedContentHandler#addAttribute(String, String, String, String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   519
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   520
    public void addAttribute(
7f561c08de6b Initial load
duke
parents:
diff changeset
   521
        String uri,
7f561c08de6b Initial load
duke
parents:
diff changeset
   522
        String localName,
7f561c08de6b Initial load
duke
parents:
diff changeset
   523
        String rawName,
7f561c08de6b Initial load
duke
parents:
diff changeset
   524
        String type,
7f561c08de6b Initial load
duke
parents:
diff changeset
   525
        String value,
7f561c08de6b Initial load
duke
parents:
diff changeset
   526
        boolean XSLAttribute)
7f561c08de6b Initial load
duke
parents:
diff changeset
   527
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   528
        // do nothing, just forget all about the attribute
7f561c08de6b Initial load
duke
parents:
diff changeset
   529
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   530
7f561c08de6b Initial load
duke
parents:
diff changeset
   531
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   532
     * @see org.xml.sax.ext.LexicalHandler#endCDATA()
7f561c08de6b Initial load
duke
parents:
diff changeset
   533
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   534
    public void endCDATA() throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   535
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   536
        // do nothing
7f561c08de6b Initial load
duke
parents:
diff changeset
   537
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   538
7f561c08de6b Initial load
duke
parents:
diff changeset
   539
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   540
     * @see ExtendedContentHandler#endElement(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   541
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   542
    public void endElement(String elemName) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   543
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   544
        if (m_tracer != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   545
            super.fireEndElem(elemName);
7f561c08de6b Initial load
duke
parents:
diff changeset
   546
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   547
7f561c08de6b Initial load
duke
parents:
diff changeset
   548
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   549
     * From XSLTC
7f561c08de6b Initial load
duke
parents:
diff changeset
   550
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   551
    public void startElement(
7f561c08de6b Initial load
duke
parents:
diff changeset
   552
    String elementNamespaceURI,
7f561c08de6b Initial load
duke
parents:
diff changeset
   553
    String elementLocalName,
7f561c08de6b Initial load
duke
parents:
diff changeset
   554
    String elementName)
7f561c08de6b Initial load
duke
parents:
diff changeset
   555
    throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   556
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   557
        if (m_needToCallStartDocument)
7f561c08de6b Initial load
duke
parents:
diff changeset
   558
            startDocumentInternal();
7f561c08de6b Initial load
duke
parents:
diff changeset
   559
        // time to fire off startlement event.
7f561c08de6b Initial load
duke
parents:
diff changeset
   560
        if (m_tracer != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   561
            super.fireStartElem(elementName);
7f561c08de6b Initial load
duke
parents:
diff changeset
   562
            this.firePseudoAttributes();
7f561c08de6b Initial load
duke
parents:
diff changeset
   563
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   564
7f561c08de6b Initial load
duke
parents:
diff changeset
   565
        return;
7f561c08de6b Initial load
duke
parents:
diff changeset
   566
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   567
7f561c08de6b Initial load
duke
parents:
diff changeset
   568
7f561c08de6b Initial load
duke
parents:
diff changeset
   569
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   570
     * From XSLTC
7f561c08de6b Initial load
duke
parents:
diff changeset
   571
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   572
    public void characters(String characters)
7f561c08de6b Initial load
duke
parents:
diff changeset
   573
    throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   574
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   575
        final int length = characters.length();
7f561c08de6b Initial load
duke
parents:
diff changeset
   576
        if (length > m_charsBuff.length)
7f561c08de6b Initial load
duke
parents:
diff changeset
   577
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   578
            m_charsBuff = new char[length*2 + 1];
7f561c08de6b Initial load
duke
parents:
diff changeset
   579
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   580
        characters.getChars(0, length, m_charsBuff, 0);
7f561c08de6b Initial load
duke
parents:
diff changeset
   581
        characters(m_charsBuff, 0, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   582
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   583
7f561c08de6b Initial load
duke
parents:
diff changeset
   584
7f561c08de6b Initial load
duke
parents:
diff changeset
   585
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   586
     * From XSLTC
7f561c08de6b Initial load
duke
parents:
diff changeset
   587
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   588
    public void addAttribute(String name, String value)
7f561c08de6b Initial load
duke
parents:
diff changeset
   589
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   590
        // do nothing, forget about the attribute
7f561c08de6b Initial load
duke
parents:
diff changeset
   591
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   592
7f561c08de6b Initial load
duke
parents:
diff changeset
   593
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   594
     * Add a unique attribute
7f561c08de6b Initial load
duke
parents:
diff changeset
   595
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   596
    public void addUniqueAttribute(String qName, String value, int flags)
7f561c08de6b Initial load
duke
parents:
diff changeset
   597
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   598
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   599
        // do nothing, forget about the attribute
7f561c08de6b Initial load
duke
parents:
diff changeset
   600
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   601
7f561c08de6b Initial load
duke
parents:
diff changeset
   602
    public boolean startPrefixMapping(
7f561c08de6b Initial load
duke
parents:
diff changeset
   603
        String prefix,
7f561c08de6b Initial load
duke
parents:
diff changeset
   604
        String uri,
7f561c08de6b Initial load
duke
parents:
diff changeset
   605
        boolean shouldFlush)
7f561c08de6b Initial load
duke
parents:
diff changeset
   606
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   607
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   608
        // no namespace support for HTML
7f561c08de6b Initial load
duke
parents:
diff changeset
   609
        return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   610
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   611
7f561c08de6b Initial load
duke
parents:
diff changeset
   612
7f561c08de6b Initial load
duke
parents:
diff changeset
   613
    public void startPrefixMapping(String prefix, String uri)
7f561c08de6b Initial load
duke
parents:
diff changeset
   614
        throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   615
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   616
        // no namespace support for HTML
7f561c08de6b Initial load
duke
parents:
diff changeset
   617
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   618
7f561c08de6b Initial load
duke
parents:
diff changeset
   619
7f561c08de6b Initial load
duke
parents:
diff changeset
   620
    public void namespaceAfterStartElement(
7f561c08de6b Initial load
duke
parents:
diff changeset
   621
        final String prefix,
7f561c08de6b Initial load
duke
parents:
diff changeset
   622
        final String uri)
7f561c08de6b Initial load
duke
parents:
diff changeset
   623
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   624
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   625
        // no namespace support for HTML
7f561c08de6b Initial load
duke
parents:
diff changeset
   626
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   627
7f561c08de6b Initial load
duke
parents:
diff changeset
   628
    public void flushPending() throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   629
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   630
            if (m_needToCallStartDocument)
7f561c08de6b Initial load
duke
parents:
diff changeset
   631
            {
7f561c08de6b Initial load
duke
parents:
diff changeset
   632
                startDocumentInternal();
7f561c08de6b Initial load
duke
parents:
diff changeset
   633
                m_needToCallStartDocument = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   634
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   635
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   636
}