src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToUnknownStream.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
/*
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one or more
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
     7
 * contributor license agreements.  See the NOTICE file distributed with
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
     8
 * this work for additional information regarding copyright ownership.
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
     9
 * The ASF licenses this file to You under the Apache License, Version 2.0
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
    10
 * (the "License"); you may not use this file except in compliance with
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
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
 */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
    21
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
package com.sun.org.apache.xml.internal.serializer;
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
import java.io.IOException;
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import java.io.OutputStream;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import java.io.Writer;
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    27
import java.util.ArrayList;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    28
import java.util.List;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
import java.util.Properties;
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
import javax.xml.transform.SourceLocator;
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
import javax.xml.transform.Transformer;
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
import org.w3c.dom.Node;
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
import org.xml.sax.Attributes;
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
import org.xml.sax.ContentHandler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
import org.xml.sax.Locator;
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
import org.xml.sax.SAXException;
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
 *This class wraps another SerializationHandler. The wrapped object will either
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
 * handler XML or HTML, which is not known until a little later when the first XML
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 * tag is seen.  If the first tag is <html> then the wrapped object is an HTML
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * handler, otherwise it is an XML handler.
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 * This class effectively caches the first few calls to it then passes them
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 * on to the wrapped handler (once it exists).  After that subsequent calls a
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
 * simply passed directly to the wrapped handler.
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
 * The user of this class doesn't know if the output is ultimatley XML or HTML.
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
 * This class is not a public API, it is public because it is used within Xalan.
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
 * @xsl.usage internal
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
public final class ToUnknownStream extends SerializerBase
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
{
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
     * The wrapped handler, initially XML but possibly switched to HTML
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
    private SerializationHandler m_handler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
     * A String with no characters
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
    private static final String EMPTYSTRING = "";
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
     * true if the underlying handler (XML or HTML) is fully initialized
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
    private boolean m_wrapped_handler_not_initialized = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
     * the prefix of the very first tag in the document
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
    private String m_firstElementPrefix;
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
    74
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
     * the element name (including any prefix) of the very first tag in the document
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
    private String m_firstElementName;
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
     * the namespace URI associated with the first element
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
    private String m_firstElementURI;
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
     * the local name (no prefix) associated with the first element
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
    private String m_firstElementLocalName = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
     * true if the first tag has been emitted to the wrapped handler
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
    private boolean m_firstTagNotEmitted = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
     * A collection of namespace URI's (only for first element).
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
     * _namespacePrefix has the matching prefix for these URI's
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
     */
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    99
    private List<String> m_namespaceURI = null;
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   100
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
     * A collection of namespace Prefix (only for first element)
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
     * _namespaceURI has the matching URIs for these prefix'
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
     */
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   105
    private List<String> m_namespacePrefix = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
     * true if startDocument() was called before the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
     * was initialized
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
    private boolean m_needToCallStartDocument = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
     * Default constructor.
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
     * Initially this object wraps an XML Stream object, so _handler is never null.
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
     * That may change later to an HTML Stream object.
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   118
    public ToUnknownStream() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
        m_handler = new ToXMLStream();
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
     * @see Serializer#asContentHandler()
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
     * @return the wrapped XML or HTML handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   126
    public ContentHandler asContentHandler() throws IOException {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
        /* don't return the real handler ( m_handler ) because
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
         * that would expose the real handler to the outside.
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
         * Keep m_handler private so it can be internally swapped
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
         * to an HTML handler.
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
        return this;
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
     * @see SerializationHandler#close()
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   138
    public void close() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
        m_handler.close();
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
     * @see Serializer#getOutputFormat()
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
     * @return the properties of the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   146
    public Properties getOutputFormat() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
        return m_handler.getOutputFormat();
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
     * @see Serializer#getOutputStream()
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
     * @return the OutputStream of the underlying XML or HTML handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   154
    public OutputStream getOutputStream() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
        return m_handler.getOutputStream();
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
     * @see Serializer#getWriter()
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
     * @return the Writer of the underlying XML or HTML handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   162
    public Writer getWriter() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
        return m_handler.getWriter();
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
     * passes the call on to the underlying HTML or XML handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
     * @see Serializer#reset()
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
     * @return ???
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   171
    public boolean reset() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
        return m_handler.reset();
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
     * Converts the DOM node to output
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
     * @param node the DOM node to transform to output
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
     * @see DOMSerializer#serialize(Node)
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   181
    public void serialize(Node node) throws IOException {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   182
        if (m_firstTagNotEmitted) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
        m_handler.serialize(node);
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
     * @see SerializationHandler#setEscaping(boolean)
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   191
    public boolean setEscaping(boolean escape) throws SAXException {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
        return m_handler.setEscaping(escape);
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
     * Set the properties of the handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
     * @param format the output properties to set
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
     * @see Serializer#setOutputFormat(Properties)
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   200
    public void setOutputFormat(Properties format) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
        m_handler.setOutputFormat(format);
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
     * Sets the output stream to write to
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
     * @param output the OutputStream to write to
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
     * @see Serializer#setOutputStream(OutputStream)
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   209
    public void setOutputStream(OutputStream output) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
        m_handler.setOutputStream(output);
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
     * Sets the writer to write to
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
     * @param writer the writer to write to
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
     * @see Serializer#setWriter(Writer)
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   218
    public void setWriter(Writer writer) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
        m_handler.setWriter(writer);
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
     * Adds an attribute to the currenly open tag
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
     * @param uri the URI of a namespace
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
     * @param localName the attribute name, without prefix
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
     * @param rawName the attribute name, with prefix (if any)
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
     * @param type the type of the attribute, typically "CDATA"
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
     * @param value the value of the parameter
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
     * @param XSLAttribute true if this attribute is coming from an xsl:attribute element
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
     * @see ExtendedContentHandler#addAttribute(String, String, String, String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   232
    public void addAttribute(String uri, String localName, String rawName,
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   233
                             String type, String value)
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
        addAttribute(uri, localName, rawName, type, value, false);
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
     * Adds an attribute to the currenly open tag
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
     * @param uri the URI of a namespace
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
     * @param localName the attribute name, without prefix
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
     * @param rawName the attribute name, with prefix (if any)
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
     * @param type the type of the attribute, typically "CDATA"
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
     * @param value the value of the parameter
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
     * @param XSLAttribute true if this attribute is coming from an xsl:attribute element
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
     * @see ExtendedContentHandler#addAttribute(String, String, String, String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   249
    public void addAttribute(String uri, String localName, String rawName,
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   250
                             String type, String value, boolean XSLAttribute)
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
    {
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   253
        if (m_firstTagNotEmitted) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
        m_handler.addAttribute(uri, localName, rawName, type, value, XSLAttribute);
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
    }
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   258
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
     * Adds an attribute to the currenly open tag
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
     * @param rawName the attribute name, with prefix (if any)
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
     * @param value the value of the parameter
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
     * @see ExtendedContentHandler#addAttribute(String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   265
    public void addAttribute(String rawName, String value) {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   266
        if (m_firstTagNotEmitted) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   269
        m_handler.addAttribute(rawName, value);
7f561c08de6b Initial load
duke
parents:
diff changeset
   270
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
7f561c08de6b Initial load
duke
parents:
diff changeset
   272
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   273
     * Adds a unique attribute to the currenly open tag
7f561c08de6b Initial load
duke
parents:
diff changeset
   274
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   275
    public void addUniqueAttribute(String rawName, String value, int flags)
7f561c08de6b Initial load
duke
parents:
diff changeset
   276
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   277
    {
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   278
        if (m_firstTagNotEmitted) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   279
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   280
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   281
        m_handler.addUniqueAttribute(rawName, value, flags);
7f561c08de6b Initial load
duke
parents:
diff changeset
   282
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   283
7f561c08de6b Initial load
duke
parents:
diff changeset
   284
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   285
     * Converts the String to a character array and calls the SAX method
7f561c08de6b Initial load
duke
parents:
diff changeset
   286
     * characters(char[],int,int);
7f561c08de6b Initial load
duke
parents:
diff changeset
   287
     *
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   288
     * @param chars The string of characters to process.
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   289
     *
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   290
     * @throws org.xml.sax.SAXException
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   291
     *
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   292
     * @see ExtendedContentHandler#characters(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   293
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   294
    public void characters(String chars) throws SAXException {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   295
        final int len = (chars == null) ? 0 : chars.length();
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   296
        if (len > m_charsBuff.length) {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   297
            m_charsBuff = new char[len * 2 + 1];
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   298
        }
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   299
        if (len > 0) {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   300
            chars.getChars(0, len, m_charsBuff, 0);
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   301
        }
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   302
        this.characters(m_charsBuff, 0, len);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   303
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   304
7f561c08de6b Initial load
duke
parents:
diff changeset
   305
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   306
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   307
     * @see ExtendedContentHandler#endElement(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   308
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   309
    public void endElement(String elementName) throws SAXException {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   310
        if (m_firstTagNotEmitted) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   311
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   312
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   313
        m_handler.endElement(elementName);
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
     * @see org.xml.sax.ContentHandler#startPrefixMapping(String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   318
     * @param prefix The prefix that maps to the URI
7f561c08de6b Initial load
duke
parents:
diff changeset
   319
     * @param uri The URI for the namespace
7f561c08de6b Initial load
duke
parents:
diff changeset
   320
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   321
    public void startPrefixMapping(String prefix, String uri) throws SAXException {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   322
        this.startPrefixMapping(prefix,uri, true);
7f561c08de6b Initial load
duke
parents:
diff changeset
   323
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   324
7f561c08de6b Initial load
duke
parents:
diff changeset
   325
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   326
     * This method is used when a prefix/uri namespace mapping
7f561c08de6b Initial load
duke
parents:
diff changeset
   327
     * is indicated after the element was started with a
7f561c08de6b Initial load
duke
parents:
diff changeset
   328
     * startElement() and before and endElement().
7f561c08de6b Initial load
duke
parents:
diff changeset
   329
     * startPrefixMapping(prefix,uri) would be used before the
7f561c08de6b Initial load
duke
parents:
diff changeset
   330
     * startElement() call.
7f561c08de6b Initial load
duke
parents:
diff changeset
   331
     * @param uri the URI of the namespace
7f561c08de6b Initial load
duke
parents:
diff changeset
   332
     * @param prefix the prefix associated with the given URI.
7f561c08de6b Initial load
duke
parents:
diff changeset
   333
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   334
     * @see ExtendedContentHandler#namespaceAfterStartElement(String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   335
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   336
    public void namespaceAfterStartElement(String prefix, String uri)
7f561c08de6b Initial load
duke
parents:
diff changeset
   337
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   338
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   339
        // hack for XSLTC with finding URI for default namespace
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   340
        if (m_firstTagNotEmitted &&
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   341
            m_firstElementURI == null &&
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   342
            m_firstElementName != null)
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   343
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   344
            String prefix1 = getPrefixPart(m_firstElementName);
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   345
            if (prefix1 == null && EMPTYSTRING.equals(prefix)) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   346
                // the elements URI is not known yet, and it
7f561c08de6b Initial load
duke
parents:
diff changeset
   347
                // doesn't have a prefix, and we are currently
7f561c08de6b Initial load
duke
parents:
diff changeset
   348
                // setting the uri for prefix "", so we have
7f561c08de6b Initial load
duke
parents:
diff changeset
   349
                // the uri for the element... lets remember it
7f561c08de6b Initial load
duke
parents:
diff changeset
   350
                m_firstElementURI = uri;
7f561c08de6b Initial load
duke
parents:
diff changeset
   351
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   352
        }
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   353
        startPrefixMapping(prefix, uri, false);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   354
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   355
7f561c08de6b Initial load
duke
parents:
diff changeset
   356
    public boolean startPrefixMapping(String prefix, String uri, boolean shouldFlush)
7f561c08de6b Initial load
duke
parents:
diff changeset
   357
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   358
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   359
        boolean pushed = false;
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   360
        if (m_firstTagNotEmitted) {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   361
            if (m_firstElementName != null && shouldFlush) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   362
                /* we've already seen a startElement, and this is a prefix mapping
7f561c08de6b Initial load
duke
parents:
diff changeset
   363
                 * for the up coming element, so flush the old element
7f561c08de6b Initial load
duke
parents:
diff changeset
   364
                 * then send this event on its way.
7f561c08de6b Initial load
duke
parents:
diff changeset
   365
                 */
7f561c08de6b Initial load
duke
parents:
diff changeset
   366
                flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   367
                pushed = m_handler.startPrefixMapping(prefix, uri, shouldFlush);
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   368
            } else {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   369
                if (m_namespacePrefix == null) {
24888
2e493ac78624 8041523: Xerces Update: Serializer improvements from Xalan
joehw
parents: 12457
diff changeset
   370
                    m_namespacePrefix = new ArrayList<>();
2e493ac78624 8041523: Xerces Update: Serializer improvements from Xalan
joehw
parents: 12457
diff changeset
   371
                    m_namespaceURI = new ArrayList<>();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   372
                }
24888
2e493ac78624 8041523: Xerces Update: Serializer improvements from Xalan
joehw
parents: 12457
diff changeset
   373
                m_namespacePrefix.add(prefix);
2e493ac78624 8041523: Xerces Update: Serializer improvements from Xalan
joehw
parents: 12457
diff changeset
   374
                m_namespaceURI.add(uri);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   375
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   376
                if (m_firstElementURI == null) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   377
                    if (prefix.equals(m_firstElementPrefix))
7f561c08de6b Initial load
duke
parents:
diff changeset
   378
                        m_firstElementURI = uri;
7f561c08de6b Initial load
duke
parents:
diff changeset
   379
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   380
            }
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   381
        } else {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   382
            pushed = m_handler.startPrefixMapping(prefix, uri, shouldFlush);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   383
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   384
        return pushed;
7f561c08de6b Initial load
duke
parents:
diff changeset
   385
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   386
7f561c08de6b Initial load
duke
parents:
diff changeset
   387
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   388
      * This method cannot be cached because default is different in
7f561c08de6b Initial load
duke
parents:
diff changeset
   389
      * HTML and XML (we need more than a boolean).
7f561c08de6b Initial load
duke
parents:
diff changeset
   390
      */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   391
    public void setVersion(String version) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   392
        m_handler.setVersion(version);
7f561c08de6b Initial load
duke
parents:
diff changeset
   393
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   394
7f561c08de6b Initial load
duke
parents:
diff changeset
   395
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   396
     * @see org.xml.sax.ContentHandler#startDocument()
7f561c08de6b Initial load
duke
parents:
diff changeset
   397
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   398
    public void startDocument() throws SAXException {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   399
        m_needToCallStartDocument = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   400
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   401
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   402
    public void startElement(String qName) throws SAXException {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   403
        this.startElement(null, null, qName, null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   404
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   405
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   406
    public void startElement(String namespaceURI, String localName,
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   407
                             String qName) throws SAXException {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   408
        this.startElement(namespaceURI, localName, qName, null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   409
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   410
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   411
    public void startElement(String namespaceURI, String localName,
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   412
                             String elementName, Attributes atts)
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   413
        throws SAXException
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   414
    {
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   415
        if (m_needToCallSetDocumentInfo) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   416
            super.setDocumentInfo();
7f561c08de6b Initial load
duke
parents:
diff changeset
   417
            m_needToCallSetDocumentInfo = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   418
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   419
7f561c08de6b Initial load
duke
parents:
diff changeset
   420
        /* we are notified of the start of an element */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   421
        if (m_firstTagNotEmitted) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   422
            /* we have not yet sent the first element on its way */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   423
            if (m_firstElementName != null) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   424
                /* this is not the first element, but a later one.
7f561c08de6b Initial load
duke
parents:
diff changeset
   425
                 * But we have the old element pending, so flush it out,
7f561c08de6b Initial load
duke
parents:
diff changeset
   426
                 * then send this one on its way.
7f561c08de6b Initial load
duke
parents:
diff changeset
   427
                 */
7f561c08de6b Initial load
duke
parents:
diff changeset
   428
                flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   429
                m_handler.startElement(namespaceURI, localName, elementName,  atts);
7f561c08de6b Initial load
duke
parents:
diff changeset
   430
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   431
            else
7f561c08de6b Initial load
duke
parents:
diff changeset
   432
            {
7f561c08de6b Initial load
duke
parents:
diff changeset
   433
                /* this is the very first element that we have seen,
7f561c08de6b Initial load
duke
parents:
diff changeset
   434
                 * so save it for flushing later.  We may yet get to know its
7f561c08de6b Initial load
duke
parents:
diff changeset
   435
                 * URI due to added attributes.
7f561c08de6b Initial load
duke
parents:
diff changeset
   436
                 */
7f561c08de6b Initial load
duke
parents:
diff changeset
   437
7f561c08de6b Initial load
duke
parents:
diff changeset
   438
                m_wrapped_handler_not_initialized = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   439
                m_firstElementName = elementName;
7f561c08de6b Initial load
duke
parents:
diff changeset
   440
7f561c08de6b Initial load
duke
parents:
diff changeset
   441
                // null if not known
7f561c08de6b Initial load
duke
parents:
diff changeset
   442
                m_firstElementPrefix = getPrefixPartUnknown(elementName);
7f561c08de6b Initial load
duke
parents:
diff changeset
   443
7f561c08de6b Initial load
duke
parents:
diff changeset
   444
                // null if not known
7f561c08de6b Initial load
duke
parents:
diff changeset
   445
                m_firstElementURI = namespaceURI;
7f561c08de6b Initial load
duke
parents:
diff changeset
   446
7f561c08de6b Initial load
duke
parents:
diff changeset
   447
                // null if not known
7f561c08de6b Initial load
duke
parents:
diff changeset
   448
                m_firstElementLocalName = localName;
7f561c08de6b Initial load
duke
parents:
diff changeset
   449
7f561c08de6b Initial load
duke
parents:
diff changeset
   450
                if (m_tracer != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   451
                    firePseudoElement(elementName);
7f561c08de6b Initial load
duke
parents:
diff changeset
   452
7f561c08de6b Initial load
duke
parents:
diff changeset
   453
                /* we don't want to call our own addAttributes, which
7f561c08de6b Initial load
duke
parents:
diff changeset
   454
                 * merely delegates to the wrapped handler, but we want to
7f561c08de6b Initial load
duke
parents:
diff changeset
   455
                 * add these attributes to m_attributes. So me must call super.
7f561c08de6b Initial load
duke
parents:
diff changeset
   456
                 * addAttributes() In this case m_attributes is only used for the
7f561c08de6b Initial load
duke
parents:
diff changeset
   457
                 * first element, after that this class totally delegates to the
7f561c08de6b Initial load
duke
parents:
diff changeset
   458
                 * wrapped handler which is either XML or HTML.
7f561c08de6b Initial load
duke
parents:
diff changeset
   459
                 */
7f561c08de6b Initial load
duke
parents:
diff changeset
   460
                if (atts != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   461
                    super.addAttributes(atts);
7f561c08de6b Initial load
duke
parents:
diff changeset
   462
7f561c08de6b Initial load
duke
parents:
diff changeset
   463
                // if there are attributes, then lets make the flush()
7f561c08de6b Initial load
duke
parents:
diff changeset
   464
                // call the startElement on the handler and send the
7f561c08de6b Initial load
duke
parents:
diff changeset
   465
                // attributes on their way.
7f561c08de6b Initial load
duke
parents:
diff changeset
   466
                if (atts != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   467
                    flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   468
7f561c08de6b Initial load
duke
parents:
diff changeset
   469
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   470
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   471
        else
7f561c08de6b Initial load
duke
parents:
diff changeset
   472
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   473
            // this is not the first element, but a later one, so just
7f561c08de6b Initial load
duke
parents:
diff changeset
   474
            // send it on its way.
7f561c08de6b Initial load
duke
parents:
diff changeset
   475
            m_handler.startElement(namespaceURI, localName, elementName,  atts);
7f561c08de6b Initial load
duke
parents:
diff changeset
   476
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   477
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   478
7f561c08de6b Initial load
duke
parents:
diff changeset
   479
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   480
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   481
     * @see ExtendedLexicalHandler#comment(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   482
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   483
    public void comment(String comment) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   484
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   485
        if (m_firstTagNotEmitted && m_firstElementName != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   486
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   487
            emitFirstTag();
7f561c08de6b Initial load
duke
parents:
diff changeset
   488
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   489
        else if (m_needToCallStartDocument)
7f561c08de6b Initial load
duke
parents:
diff changeset
   490
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   491
            m_handler.startDocument();
7f561c08de6b Initial load
duke
parents:
diff changeset
   492
            m_needToCallStartDocument = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   493
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   494
7f561c08de6b Initial load
duke
parents:
diff changeset
   495
        m_handler.comment(comment);
7f561c08de6b Initial load
duke
parents:
diff changeset
   496
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   497
7f561c08de6b Initial load
duke
parents:
diff changeset
   498
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   499
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   500
     * @see XSLOutputAttributes#getDoctypePublic()
7f561c08de6b Initial load
duke
parents:
diff changeset
   501
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   502
    public String getDoctypePublic()
7f561c08de6b Initial load
duke
parents:
diff changeset
   503
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   504
7f561c08de6b Initial load
duke
parents:
diff changeset
   505
        return m_handler.getDoctypePublic();
7f561c08de6b Initial load
duke
parents:
diff changeset
   506
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   507
7f561c08de6b Initial load
duke
parents:
diff changeset
   508
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   509
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   510
     * @see XSLOutputAttributes#getDoctypeSystem()
7f561c08de6b Initial load
duke
parents:
diff changeset
   511
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   512
    public String getDoctypeSystem()
7f561c08de6b Initial load
duke
parents:
diff changeset
   513
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   514
        return m_handler.getDoctypeSystem();
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
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   519
     * @see XSLOutputAttributes#getEncoding()
7f561c08de6b Initial load
duke
parents:
diff changeset
   520
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   521
    public String getEncoding()
7f561c08de6b Initial load
duke
parents:
diff changeset
   522
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   523
        return m_handler.getEncoding();
7f561c08de6b Initial load
duke
parents:
diff changeset
   524
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   525
7f561c08de6b Initial load
duke
parents:
diff changeset
   526
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   527
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   528
     * @see XSLOutputAttributes#getIndent()
7f561c08de6b Initial load
duke
parents:
diff changeset
   529
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   530
    public boolean getIndent()
7f561c08de6b Initial load
duke
parents:
diff changeset
   531
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   532
        return m_handler.getIndent();
7f561c08de6b Initial load
duke
parents:
diff changeset
   533
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   534
7f561c08de6b Initial load
duke
parents:
diff changeset
   535
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   536
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   537
     * @see XSLOutputAttributes#getIndentAmount()
7f561c08de6b Initial load
duke
parents:
diff changeset
   538
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   539
    public int getIndentAmount()
7f561c08de6b Initial load
duke
parents:
diff changeset
   540
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   541
        return m_handler.getIndentAmount();
7f561c08de6b Initial load
duke
parents:
diff changeset
   542
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   543
7f561c08de6b Initial load
duke
parents:
diff changeset
   544
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   545
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   546
     * @see XSLOutputAttributes#getMediaType()
7f561c08de6b Initial load
duke
parents:
diff changeset
   547
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   548
    public String getMediaType()
7f561c08de6b Initial load
duke
parents:
diff changeset
   549
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   550
        return m_handler.getMediaType();
7f561c08de6b Initial load
duke
parents:
diff changeset
   551
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   552
7f561c08de6b Initial load
duke
parents:
diff changeset
   553
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   554
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   555
     * @see XSLOutputAttributes#getOmitXMLDeclaration()
7f561c08de6b Initial load
duke
parents:
diff changeset
   556
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   557
    public boolean getOmitXMLDeclaration()
7f561c08de6b Initial load
duke
parents:
diff changeset
   558
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   559
        return m_handler.getOmitXMLDeclaration();
7f561c08de6b Initial load
duke
parents:
diff changeset
   560
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   561
7f561c08de6b Initial load
duke
parents:
diff changeset
   562
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   563
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   564
     * @see XSLOutputAttributes#getStandalone()
7f561c08de6b Initial load
duke
parents:
diff changeset
   565
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   566
    public String getStandalone()
7f561c08de6b Initial load
duke
parents:
diff changeset
   567
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   568
        return m_handler.getStandalone();
7f561c08de6b Initial load
duke
parents:
diff changeset
   569
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   570
7f561c08de6b Initial load
duke
parents:
diff changeset
   571
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   572
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   573
     * @see XSLOutputAttributes#getVersion()
7f561c08de6b Initial load
duke
parents:
diff changeset
   574
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   575
    public String getVersion() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   576
        return m_handler.getVersion();
7f561c08de6b Initial load
duke
parents:
diff changeset
   577
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   578
7f561c08de6b Initial load
duke
parents:
diff changeset
   579
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   580
     * @see XSLOutputAttributes#setDoctype(String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   581
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   582
    public void setDoctype(String system, String pub) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   583
        m_handler.setDoctypePublic(pub);
7f561c08de6b Initial load
duke
parents:
diff changeset
   584
        m_handler.setDoctypeSystem(system);
7f561c08de6b Initial load
duke
parents:
diff changeset
   585
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   586
7f561c08de6b Initial load
duke
parents:
diff changeset
   587
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   588
     * Set the doctype in the underlying XML handler. Remember that this method
7f561c08de6b Initial load
duke
parents:
diff changeset
   589
     * was called, just in case we need to transfer this doctype to an HTML handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   590
     * @param doctype the public doctype to set
7f561c08de6b Initial load
duke
parents:
diff changeset
   591
     * @see XSLOutputAttributes#setDoctypePublic(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   592
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   593
    public void setDoctypePublic(String doctype) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   594
        m_handler.setDoctypePublic(doctype);
7f561c08de6b Initial load
duke
parents:
diff changeset
   595
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   596
7f561c08de6b Initial load
duke
parents:
diff changeset
   597
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   598
     * Set the doctype in the underlying XML handler. Remember that this method
7f561c08de6b Initial load
duke
parents:
diff changeset
   599
     * was called, just in case we need to transfer this doctype to an HTML handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   600
     * @param doctype the system doctype to set
7f561c08de6b Initial load
duke
parents:
diff changeset
   601
     * @see XSLOutputAttributes#setDoctypeSystem(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   602
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   603
    public void setDoctypeSystem(String doctype) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   604
        m_handler.setDoctypeSystem(doctype);
7f561c08de6b Initial load
duke
parents:
diff changeset
   605
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   606
7f561c08de6b Initial load
duke
parents:
diff changeset
   607
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   608
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   609
     * @see XSLOutputAttributes#setEncoding(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   610
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   611
    public void setEncoding(String encoding) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   612
        m_handler.setEncoding(encoding);
7f561c08de6b Initial load
duke
parents:
diff changeset
   613
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   614
7f561c08de6b Initial load
duke
parents:
diff changeset
   615
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   616
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   617
     * @see XSLOutputAttributes#setIndent(boolean)
7f561c08de6b Initial load
duke
parents:
diff changeset
   618
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   619
    public void setIndent(boolean indent) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   620
        m_handler.setIndent(indent);
7f561c08de6b Initial load
duke
parents:
diff changeset
   621
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   622
7f561c08de6b Initial load
duke
parents:
diff changeset
   623
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   624
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   625
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   626
    public void setIndentAmount(int value) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   627
        m_handler.setIndentAmount(value);
7f561c08de6b Initial load
duke
parents:
diff changeset
   628
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   629
7f561c08de6b Initial load
duke
parents:
diff changeset
   630
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   631
     * @see XSLOutputAttributes#setMediaType(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   632
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   633
    public void setMediaType(String mediaType) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   634
        m_handler.setMediaType(mediaType);
7f561c08de6b Initial load
duke
parents:
diff changeset
   635
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   636
7f561c08de6b Initial load
duke
parents:
diff changeset
   637
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   638
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   639
     * @see XSLOutputAttributes#setOmitXMLDeclaration(boolean)
7f561c08de6b Initial load
duke
parents:
diff changeset
   640
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   641
    public void setOmitXMLDeclaration(boolean b) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   642
        m_handler.setOmitXMLDeclaration(b);
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
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   647
     * @see XSLOutputAttributes#setStandalone(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   648
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   649
    public void setStandalone(String standalone) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   650
        m_handler.setStandalone(standalone);
7f561c08de6b Initial load
duke
parents:
diff changeset
   651
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   652
7f561c08de6b Initial load
duke
parents:
diff changeset
   653
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   654
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   655
     * @see org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   656
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   657
    public void attributeDecl(String arg0, String arg1, String arg2,
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   658
                              String arg3, String arg4) throws SAXException {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   659
        m_handler.attributeDecl(arg0, arg1, arg2, arg3, arg4);
7f561c08de6b Initial load
duke
parents:
diff changeset
   660
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   661
7f561c08de6b Initial load
duke
parents:
diff changeset
   662
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   663
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   664
     * @see org.xml.sax.ext.DeclHandler#elementDecl(String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   665
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   666
    public void elementDecl(String arg0, String arg1) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   667
    {
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   668
        if (m_firstTagNotEmitted) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   669
            emitFirstTag();
7f561c08de6b Initial load
duke
parents:
diff changeset
   670
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   671
        m_handler.elementDecl(arg0, arg1);
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
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   676
     * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(String, String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   677
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   678
    public void externalEntityDecl(
7f561c08de6b Initial load
duke
parents:
diff changeset
   679
        String name,
7f561c08de6b Initial load
duke
parents:
diff changeset
   680
        String publicId,
7f561c08de6b Initial load
duke
parents:
diff changeset
   681
        String systemId)
7f561c08de6b Initial load
duke
parents:
diff changeset
   682
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   683
    {
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   684
        if (m_firstTagNotEmitted) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   685
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   686
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   687
        m_handler.externalEntityDecl(name, publicId, systemId);
7f561c08de6b Initial load
duke
parents:
diff changeset
   688
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   689
7f561c08de6b Initial load
duke
parents:
diff changeset
   690
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   691
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   692
     * @see org.xml.sax.ext.DeclHandler#internalEntityDecl(String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   693
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   694
    public void internalEntityDecl(String arg0, String arg1)
7f561c08de6b Initial load
duke
parents:
diff changeset
   695
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   696
    {
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   697
        if (m_firstTagNotEmitted) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   698
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   699
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   700
        m_handler.internalEntityDecl(arg0, arg1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   701
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   702
7f561c08de6b Initial load
duke
parents:
diff changeset
   703
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   704
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   705
     * @see org.xml.sax.ContentHandler#characters(char[], int, int)
7f561c08de6b Initial load
duke
parents:
diff changeset
   706
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   707
    public void characters(char[] characters, int offset, int length)
7f561c08de6b Initial load
duke
parents:
diff changeset
   708
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   709
    {
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   710
        if (m_firstTagNotEmitted) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   711
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   712
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   713
        m_handler.characters(characters, offset, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   714
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   715
7f561c08de6b Initial load
duke
parents:
diff changeset
   716
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   717
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   718
     * @see org.xml.sax.ContentHandler#endDocument()
7f561c08de6b Initial load
duke
parents:
diff changeset
   719
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   720
    public void endDocument() throws SAXException {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   721
        if (m_firstTagNotEmitted) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   722
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   723
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   724
        m_handler.endDocument();
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
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   729
     * @see org.xml.sax.ContentHandler#endElement(String, String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   730
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   731
    public void endElement(String namespaceURI, String localName, String qName)
7f561c08de6b Initial load
duke
parents:
diff changeset
   732
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   733
    {
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   734
        if (m_firstTagNotEmitted) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   735
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   736
            if (namespaceURI == null && m_firstElementURI != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   737
                namespaceURI = m_firstElementURI;
7f561c08de6b Initial load
duke
parents:
diff changeset
   738
7f561c08de6b Initial load
duke
parents:
diff changeset
   739
            if (localName == null && m_firstElementLocalName != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   740
                localName = m_firstElementLocalName;
7f561c08de6b Initial load
duke
parents:
diff changeset
   741
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   742
        m_handler.endElement(namespaceURI, localName, qName);
7f561c08de6b Initial load
duke
parents:
diff changeset
   743
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   744
7f561c08de6b Initial load
duke
parents:
diff changeset
   745
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   746
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   747
     * @see org.xml.sax.ContentHandler#endPrefixMapping(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   748
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   749
    public void endPrefixMapping(String prefix) throws SAXException {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   750
        m_handler.endPrefixMapping(prefix);
7f561c08de6b Initial load
duke
parents:
diff changeset
   751
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   752
7f561c08de6b Initial load
duke
parents:
diff changeset
   753
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   754
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   755
     * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
7f561c08de6b Initial load
duke
parents:
diff changeset
   756
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   757
    public void ignorableWhitespace(char[] ch, int start, int length)
7f561c08de6b Initial load
duke
parents:
diff changeset
   758
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   759
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   760
        if (m_firstTagNotEmitted)
7f561c08de6b Initial load
duke
parents:
diff changeset
   761
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   762
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   763
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   764
        m_handler.ignorableWhitespace(ch, start, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   765
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   766
7f561c08de6b Initial load
duke
parents:
diff changeset
   767
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   768
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   769
     * @see org.xml.sax.ContentHandler#processingInstruction(String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   770
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   771
    public void processingInstruction(String target, String data)
7f561c08de6b Initial load
duke
parents:
diff changeset
   772
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   773
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   774
          if (m_firstTagNotEmitted)
7f561c08de6b Initial load
duke
parents:
diff changeset
   775
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   776
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   777
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   778
7f561c08de6b Initial load
duke
parents:
diff changeset
   779
        m_handler.processingInstruction(target, data);
7f561c08de6b Initial load
duke
parents:
diff changeset
   780
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   781
7f561c08de6b Initial load
duke
parents:
diff changeset
   782
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   783
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   784
     * @see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
7f561c08de6b Initial load
duke
parents:
diff changeset
   785
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   786
    public void setDocumentLocator(Locator locator)
7f561c08de6b Initial load
duke
parents:
diff changeset
   787
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   788
        super.setDocumentLocator(locator);
7f561c08de6b Initial load
duke
parents:
diff changeset
   789
        m_handler.setDocumentLocator(locator);
7f561c08de6b Initial load
duke
parents:
diff changeset
   790
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   791
7f561c08de6b Initial load
duke
parents:
diff changeset
   792
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   793
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   794
     * @see org.xml.sax.ContentHandler#skippedEntity(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   795
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   796
    public void skippedEntity(String name) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   797
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   798
        m_handler.skippedEntity(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   799
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   800
7f561c08de6b Initial load
duke
parents:
diff changeset
   801
7f561c08de6b Initial load
duke
parents:
diff changeset
   802
7f561c08de6b Initial load
duke
parents:
diff changeset
   803
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   804
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   805
     * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
7f561c08de6b Initial load
duke
parents:
diff changeset
   806
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   807
    public void comment(char[] ch, int start, int length) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   808
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   809
        if (m_firstTagNotEmitted)
7f561c08de6b Initial load
duke
parents:
diff changeset
   810
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   811
            flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
   812
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   813
7f561c08de6b Initial load
duke
parents:
diff changeset
   814
        m_handler.comment(ch, start, length);
7f561c08de6b Initial load
duke
parents:
diff changeset
   815
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   816
7f561c08de6b Initial load
duke
parents:
diff changeset
   817
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   818
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   819
     * @see org.xml.sax.ext.LexicalHandler#endCDATA()
7f561c08de6b Initial load
duke
parents:
diff changeset
   820
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   821
    public void endCDATA() throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   822
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   823
7f561c08de6b Initial load
duke
parents:
diff changeset
   824
        m_handler.endCDATA();
7f561c08de6b Initial load
duke
parents:
diff changeset
   825
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   826
7f561c08de6b Initial load
duke
parents:
diff changeset
   827
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   828
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   829
     * @see org.xml.sax.ext.LexicalHandler#endDTD()
7f561c08de6b Initial load
duke
parents:
diff changeset
   830
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   831
    public void endDTD() throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   832
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   833
7f561c08de6b Initial load
duke
parents:
diff changeset
   834
        m_handler.endDTD();
7f561c08de6b Initial load
duke
parents:
diff changeset
   835
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   836
7f561c08de6b Initial load
duke
parents:
diff changeset
   837
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   838
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   839
     * @see org.xml.sax.ext.LexicalHandler#endEntity(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   840
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   841
    public void endEntity(String name) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   842
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   843
        if (m_firstTagNotEmitted)
7f561c08de6b Initial load
duke
parents:
diff changeset
   844
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   845
            emitFirstTag();
7f561c08de6b Initial load
duke
parents:
diff changeset
   846
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   847
        m_handler.endEntity(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   848
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   849
7f561c08de6b Initial load
duke
parents:
diff changeset
   850
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   851
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   852
     * @see org.xml.sax.ext.LexicalHandler#startCDATA()
7f561c08de6b Initial load
duke
parents:
diff changeset
   853
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   854
    public void startCDATA() throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   855
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   856
        m_handler.startCDATA();
7f561c08de6b Initial load
duke
parents:
diff changeset
   857
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   858
7f561c08de6b Initial load
duke
parents:
diff changeset
   859
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   860
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   861
     * @see org.xml.sax.ext.LexicalHandler#startDTD(String, String, String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   862
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   863
    public void startDTD(String name, String publicId, String systemId)
7f561c08de6b Initial load
duke
parents:
diff changeset
   864
        throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   865
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   866
        m_handler.startDTD(name, publicId, systemId);
7f561c08de6b Initial load
duke
parents:
diff changeset
   867
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   868
7f561c08de6b Initial load
duke
parents:
diff changeset
   869
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   870
     * Pass the call on to the underlying handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   871
     * @see org.xml.sax.ext.LexicalHandler#startEntity(String)
7f561c08de6b Initial load
duke
parents:
diff changeset
   872
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   873
    public void startEntity(String name) throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   874
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   875
        m_handler.startEntity(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   876
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   877
7f561c08de6b Initial load
duke
parents:
diff changeset
   878
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   879
     * Initialize the wrapped output stream (XML or HTML).
7f561c08de6b Initial load
duke
parents:
diff changeset
   880
     * If the stream handler should be HTML, then replace the XML handler with
7f561c08de6b Initial load
duke
parents:
diff changeset
   881
     * an HTML handler. After than send the starting method calls that were cached
7f561c08de6b Initial load
duke
parents:
diff changeset
   882
     * to the wrapped handler.
7f561c08de6b Initial load
duke
parents:
diff changeset
   883
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   884
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   885
    private void initStreamOutput() throws SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   886
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   887
7f561c08de6b Initial load
duke
parents:
diff changeset
   888
        // Try to rule out if this is an not to be an HTML document based on prefix
7f561c08de6b Initial load
duke
parents:
diff changeset
   889
        boolean firstElementIsHTML = isFirstElemHTML();
7f561c08de6b Initial load
duke
parents:
diff changeset
   890
7f561c08de6b Initial load
duke
parents:
diff changeset
   891
        if (firstElementIsHTML)
7f561c08de6b Initial load
duke
parents:
diff changeset
   892
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   893
            // create an HTML output handler, and initialize it
7f561c08de6b Initial load
duke
parents:
diff changeset
   894
7f561c08de6b Initial load
duke
parents:
diff changeset
   895
            // keep a reference to the old handler, ... it will soon be gone
7f561c08de6b Initial load
duke
parents:
diff changeset
   896
            SerializationHandler oldHandler = m_handler;
7f561c08de6b Initial load
duke
parents:
diff changeset
   897
7f561c08de6b Initial load
duke
parents:
diff changeset
   898
            /* We have to make sure we get an output properties with the proper
7f561c08de6b Initial load
duke
parents:
diff changeset
   899
             * defaults for the HTML method.  The easiest way to do this is to
7f561c08de6b Initial load
duke
parents:
diff changeset
   900
             * have the OutputProperties class do it.
7f561c08de6b Initial load
duke
parents:
diff changeset
   901
             */
7f561c08de6b Initial load
duke
parents:
diff changeset
   902
7f561c08de6b Initial load
duke
parents:
diff changeset
   903
            Properties htmlProperties =
7f561c08de6b Initial load
duke
parents:
diff changeset
   904
                OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
7f561c08de6b Initial load
duke
parents:
diff changeset
   905
            Serializer serializer =
7f561c08de6b Initial load
duke
parents:
diff changeset
   906
                SerializerFactory.getSerializer(htmlProperties);
7f561c08de6b Initial load
duke
parents:
diff changeset
   907
7f561c08de6b Initial load
duke
parents:
diff changeset
   908
            // The factory should be returning a ToStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   909
            // Don't know what to do if it doesn't
7f561c08de6b Initial load
duke
parents:
diff changeset
   910
            // i.e. the user has over-ridden the content-handler property
7f561c08de6b Initial load
duke
parents:
diff changeset
   911
            // for html
7f561c08de6b Initial load
duke
parents:
diff changeset
   912
            m_handler = (SerializationHandler) serializer;
7f561c08de6b Initial load
duke
parents:
diff changeset
   913
            //m_handler = new ToHTMLStream();
7f561c08de6b Initial load
duke
parents:
diff changeset
   914
7f561c08de6b Initial load
duke
parents:
diff changeset
   915
            Writer writer = oldHandler.getWriter();
7f561c08de6b Initial load
duke
parents:
diff changeset
   916
7f561c08de6b Initial load
duke
parents:
diff changeset
   917
            if (null != writer)
7f561c08de6b Initial load
duke
parents:
diff changeset
   918
                m_handler.setWriter(writer);
7f561c08de6b Initial load
duke
parents:
diff changeset
   919
            else
7f561c08de6b Initial load
duke
parents:
diff changeset
   920
            {
7f561c08de6b Initial load
duke
parents:
diff changeset
   921
                OutputStream os = oldHandler.getOutputStream();
7f561c08de6b Initial load
duke
parents:
diff changeset
   922
7f561c08de6b Initial load
duke
parents:
diff changeset
   923
                if (null != os)
7f561c08de6b Initial load
duke
parents:
diff changeset
   924
                    m_handler.setOutputStream(os);
7f561c08de6b Initial load
duke
parents:
diff changeset
   925
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   926
7f561c08de6b Initial load
duke
parents:
diff changeset
   927
            // need to copy things from the old handler to the new one here
7f561c08de6b Initial load
duke
parents:
diff changeset
   928
7f561c08de6b Initial load
duke
parents:
diff changeset
   929
            //            if (_setVersion_called)
7f561c08de6b Initial load
duke
parents:
diff changeset
   930
            //            {
7f561c08de6b Initial load
duke
parents:
diff changeset
   931
            m_handler.setVersion(oldHandler.getVersion());
7f561c08de6b Initial load
duke
parents:
diff changeset
   932
            //            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   933
            //            if (_setDoctypeSystem_called)
7f561c08de6b Initial load
duke
parents:
diff changeset
   934
            //            {
7f561c08de6b Initial load
duke
parents:
diff changeset
   935
            m_handler.setDoctypeSystem(oldHandler.getDoctypeSystem());
7f561c08de6b Initial load
duke
parents:
diff changeset
   936
            //            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   937
            //            if (_setDoctypePublic_called)
7f561c08de6b Initial load
duke
parents:
diff changeset
   938
            //            {
7f561c08de6b Initial load
duke
parents:
diff changeset
   939
            m_handler.setDoctypePublic(oldHandler.getDoctypePublic());
7f561c08de6b Initial load
duke
parents:
diff changeset
   940
            //            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   941
            //            if (_setMediaType_called)
7f561c08de6b Initial load
duke
parents:
diff changeset
   942
            //            {
7f561c08de6b Initial load
duke
parents:
diff changeset
   943
            m_handler.setMediaType(oldHandler.getMediaType());
7f561c08de6b Initial load
duke
parents:
diff changeset
   944
            //            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   945
7f561c08de6b Initial load
duke
parents:
diff changeset
   946
            m_handler.setTransformer(oldHandler.getTransformer());
7f561c08de6b Initial load
duke
parents:
diff changeset
   947
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   948
7f561c08de6b Initial load
duke
parents:
diff changeset
   949
        /* Now that we have a real wrapped handler (XML or HTML) lets
7f561c08de6b Initial load
duke
parents:
diff changeset
   950
         * pass any cached calls to it
7f561c08de6b Initial load
duke
parents:
diff changeset
   951
         */
7f561c08de6b Initial load
duke
parents:
diff changeset
   952
        // Call startDocument() if necessary
7f561c08de6b Initial load
duke
parents:
diff changeset
   953
        if (m_needToCallStartDocument)
7f561c08de6b Initial load
duke
parents:
diff changeset
   954
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
   955
            m_handler.startDocument();
7f561c08de6b Initial load
duke
parents:
diff changeset
   956
            m_needToCallStartDocument = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   957
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   958
7f561c08de6b Initial load
duke
parents:
diff changeset
   959
        // the wrapped handler is now fully initialized
7f561c08de6b Initial load
duke
parents:
diff changeset
   960
        m_wrapped_handler_not_initialized = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   961
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   962
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   963
    private void emitFirstTag() throws SAXException {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   964
        if (m_firstElementName != null) {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   965
            if (m_wrapped_handler_not_initialized) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   966
                initStreamOutput();
7f561c08de6b Initial load
duke
parents:
diff changeset
   967
                m_wrapped_handler_not_initialized = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   968
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   969
            // Output first tag
7f561c08de6b Initial load
duke
parents:
diff changeset
   970
            m_handler.startElement(m_firstElementURI, null, m_firstElementName, m_attributes);
7f561c08de6b Initial load
duke
parents:
diff changeset
   971
            // don't need the collected attributes of the first element anymore.
7f561c08de6b Initial load
duke
parents:
diff changeset
   972
            m_attributes = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   973
7f561c08de6b Initial load
duke
parents:
diff changeset
   974
            // Output namespaces of first tag
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   975
            if (m_namespacePrefix != null) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   976
                final int n = m_namespacePrefix.size();
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   977
                for (int i = 0; i < n; i++) {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   978
                    final String prefix = m_namespacePrefix.get(i);
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   979
                    final String uri = m_namespaceURI.get(i);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   980
                    m_handler.startPrefixMapping(prefix, uri, false);
7f561c08de6b Initial load
duke
parents:
diff changeset
   981
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   982
                m_namespacePrefix = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   983
                m_namespaceURI = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   984
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   985
            m_firstTagNotEmitted = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   986
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   987
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   988
7f561c08de6b Initial load
duke
parents:
diff changeset
   989
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   990
     * Utility function for calls to local-name().
7f561c08de6b Initial load
duke
parents:
diff changeset
   991
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   992
     * Don't want to override static function on SerializerBase
7f561c08de6b Initial load
duke
parents:
diff changeset
   993
     * So added Unknown suffix to method name.
7f561c08de6b Initial load
duke
parents:
diff changeset
   994
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
   995
    private String getLocalNameUnknown(String value) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   996
        int idx = value.lastIndexOf(':');
7f561c08de6b Initial load
duke
parents:
diff changeset
   997
        if (idx >= 0)
7f561c08de6b Initial load
duke
parents:
diff changeset
   998
            value = value.substring(idx + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   999
        idx = value.lastIndexOf('@');
7f561c08de6b Initial load
duke
parents:
diff changeset
  1000
        if (idx >= 0)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1001
            value = value.substring(idx + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1002
        return (value);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1003
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1004
7f561c08de6b Initial load
duke
parents:
diff changeset
  1005
    /**
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1006
     * Utility function to return prefix
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1007
     *
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1008
     * Don't want to override static function on SerializerBase
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1009
     * So added Unknown suffix to method name.
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1010
     */
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1011
    private String getPrefixPartUnknown(String qname) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1012
        final int index = qname.indexOf(':');
7f561c08de6b Initial load
duke
parents:
diff changeset
  1013
        return (index > 0) ? qname.substring(0, index) : EMPTYSTRING;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1014
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1015
7f561c08de6b Initial load
duke
parents:
diff changeset
  1016
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1017
     * Determine if the firts element in the document is <html> or <HTML>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1018
     * This uses the cached first element name, first element prefix and the
7f561c08de6b Initial load
duke
parents:
diff changeset
  1019
     * cached namespaces from previous method calls
7f561c08de6b Initial load
duke
parents:
diff changeset
  1020
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1021
     * @return true if the first element is an opening <html> tag
7f561c08de6b Initial load
duke
parents:
diff changeset
  1022
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1023
    private boolean isFirstElemHTML() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1024
        boolean isHTML;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1025
7f561c08de6b Initial load
duke
parents:
diff changeset
  1026
        // is the first tag html, not considering the prefix ?
7f561c08de6b Initial load
duke
parents:
diff changeset
  1027
        isHTML =
7f561c08de6b Initial load
duke
parents:
diff changeset
  1028
            getLocalNameUnknown(m_firstElementName).equalsIgnoreCase("html");
7f561c08de6b Initial load
duke
parents:
diff changeset
  1029
7f561c08de6b Initial load
duke
parents:
diff changeset
  1030
        // Try to rule out if this is not to be an HTML document based on URI
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1031
        if (isHTML &&
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1032
            m_firstElementURI != null &&
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1033
            !EMPTYSTRING.equals(m_firstElementURI))
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1034
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1035
            // the <html> element has a non-trivial namespace
7f561c08de6b Initial load
duke
parents:
diff changeset
  1036
            isHTML = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1037
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1038
        // Try to rule out if this is an not to be an HTML document based on prefix
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1039
        if (isHTML && m_namespacePrefix != null) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1040
            /* the first element has a name of "html", but lets check the prefix.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1041
             * If the prefix points to a namespace with a URL that is not ""
7f561c08de6b Initial load
duke
parents:
diff changeset
  1042
             * then the doecument doesn't start with an <html> tag, and isn't html
7f561c08de6b Initial load
duke
parents:
diff changeset
  1043
             */
7f561c08de6b Initial load
duke
parents:
diff changeset
  1044
            final int max = m_namespacePrefix.size();
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1045
            for (int i = 0; i < max; i++) {
24888
2e493ac78624 8041523: Xerces Update: Serializer improvements from Xalan
joehw
parents: 12457
diff changeset
  1046
                final String prefix = m_namespacePrefix.get(i);
2e493ac78624 8041523: Xerces Update: Serializer improvements from Xalan
joehw
parents: 12457
diff changeset
  1047
                final String uri = m_namespaceURI.get(i);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1048
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1049
                if (m_firstElementPrefix != null &&
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1050
                    m_firstElementPrefix.equals(prefix) &&
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1051
                    !EMPTYSTRING.equals(uri))
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1052
                {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1053
                    // The first element has a prefix, so it can't be <html>
7f561c08de6b Initial load
duke
parents:
diff changeset
  1054
                    isHTML = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1055
                    break;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1056
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1057
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1058
7f561c08de6b Initial load
duke
parents:
diff changeset
  1059
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1060
        return isHTML;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1061
    }
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1062
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1063
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1064
     * @see Serializer#asDOMSerializer()
7f561c08de6b Initial load
duke
parents:
diff changeset
  1065
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1066
    public DOMSerializer asDOMSerializer() throws IOException {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1067
        return m_handler.asDOMSerializer();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1068
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1069
7f561c08de6b Initial load
duke
parents:
diff changeset
  1070
    /**
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
  1071
     * @param URI_and_localNames a list of pairs of URI/localName
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1072
     * specified in the cdata-section-elements attribute.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
  1073
     * @see SerializationHandler#setCdataSectionElements(List)
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1074
     */
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
  1075
    public void setCdataSectionElements(List<String> URI_and_localNames) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1076
        m_handler.setCdataSectionElements(URI_and_localNames);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1077
    }
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1078
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1079
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1080
     * @see ExtendedContentHandler#addAttributes(org.xml.sax.Attributes)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1081
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1082
    public void addAttributes(Attributes atts) throws SAXException {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1083
        m_handler.addAttributes(atts);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1084
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1085
7f561c08de6b Initial load
duke
parents:
diff changeset
  1086
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1087
     * Get the current namespace mappings.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1088
     * Simply returns the mappings of the wrapped handler.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1089
     * @see ExtendedContentHandler#getNamespaceMappings()
7f561c08de6b Initial load
duke
parents:
diff changeset
  1090
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1091
    public NamespaceMappings getNamespaceMappings() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1092
        NamespaceMappings mappings = null;
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1093
        if (m_handler != null) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1094
            mappings = m_handler.getNamespaceMappings();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1095
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1096
        return mappings;
7f561c08de6b Initial load
duke
parents:
diff changeset
  1097
    }
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1098
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1099
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1100
     * @see SerializationHandler#flushPending()
7f561c08de6b Initial load
duke
parents:
diff changeset
  1101
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1102
    public void flushPending() throws SAXException {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1103
        flush();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1104
        m_handler.flushPending();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1105
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1106
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1107
    private void flush() {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1108
        try {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1109
            if (m_firstTagNotEmitted) {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1110
                emitFirstTag();
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1111
            }
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1112
            if (m_needToCallStartDocument) {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1113
                m_handler.startDocument();
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1114
                m_needToCallStartDocument = false;
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1115
            }
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1116
        } catch(SAXException e) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1117
            throw new RuntimeException(e.toString());
7f561c08de6b Initial load
duke
parents:
diff changeset
  1118
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1119
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1120
7f561c08de6b Initial load
duke
parents:
diff changeset
  1121
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1122
     * @see ExtendedContentHandler#getPrefix
7f561c08de6b Initial load
duke
parents:
diff changeset
  1123
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1124
    public String getPrefix(String namespaceURI) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1125
        return m_handler.getPrefix(namespaceURI);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1126
    }
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1127
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1128
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1129
     * @see ExtendedContentHandler#entityReference(java.lang.String)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1130
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1131
    public void entityReference(String entityName) throws SAXException {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1132
        m_handler.entityReference(entityName);
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
     * @see ExtendedContentHandler#getNamespaceURI(java.lang.String, boolean)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1137
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1138
    public String getNamespaceURI(String qname, boolean isElement) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1139
        return m_handler.getNamespaceURI(qname, isElement);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1140
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1141
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1142
    public String getNamespaceURIFromPrefix(String prefix) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1143
        return m_handler.getNamespaceURIFromPrefix(prefix);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1144
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1145
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1146
    public void setTransformer(Transformer t) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1147
        m_handler.setTransformer(t);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1148
        if ((t instanceof SerializerTrace) &&
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1149
            (((SerializerTrace) t).hasTraceListeners()))
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1150
        {
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1151
            m_tracer = (SerializerTrace) t;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1152
        } else {
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1153
            m_tracer = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1154
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1155
    }
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1156
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1157
    public Transformer getTransformer() {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1158
        return m_handler.getTransformer();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1159
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1160
7f561c08de6b Initial load
duke
parents:
diff changeset
  1161
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1162
     * @see SerializationHandler#setContentHandler(org.xml.sax.ContentHandler)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1163
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1164
    public void setContentHandler(ContentHandler ch) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1165
        m_handler.setContentHandler(ch);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1166
    }
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1167
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1168
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
  1169
     * This method is used to set the source locator, which might be used to
7f561c08de6b Initial load
duke
parents:
diff changeset
  1170
     * generated an error message.
7f561c08de6b Initial load
duke
parents:
diff changeset
  1171
     * @param locator the source locator
7f561c08de6b Initial load
duke
parents:
diff changeset
  1172
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
  1173
     * @see ExtendedContentHandler#setSourceLocator(javax.xml.transform.SourceLocator)
7f561c08de6b Initial load
duke
parents:
diff changeset
  1174
     */
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1175
    public void setSourceLocator(SourceLocator locator) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1176
        m_handler.setSourceLocator(locator);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1177
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1178
42249
39ec1a731d99 8169772: [JAXP] XALAN: Transformation of DOM with null valued text node causes NPE
clanger
parents: 25868
diff changeset
  1179
    protected void firePseudoElement(String elementName) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1180
        if (m_tracer != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
  1181
            StringBuffer sb = new StringBuffer();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1182
7f561c08de6b Initial load
duke
parents:
diff changeset
  1183
            sb.append('<');
7f561c08de6b Initial load
duke
parents:
diff changeset
  1184
            sb.append(elementName);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1185
7f561c08de6b Initial load
duke
parents:
diff changeset
  1186
            // convert the StringBuffer to a char array and
7f561c08de6b Initial load
duke
parents:
diff changeset
  1187
            // emit the trace event that these characters "might"
7f561c08de6b Initial load
duke
parents:
diff changeset
  1188
            // be written
7f561c08de6b Initial load
duke
parents:
diff changeset
  1189
            char ch[] = sb.toString().toCharArray();
7f561c08de6b Initial load
duke
parents:
diff changeset
  1190
            m_tracer.fireGenerateEvent(
7f561c08de6b Initial load
duke
parents:
diff changeset
  1191
                SerializerTrace.EVENTTYPE_OUTPUT_PSEUDO_CHARACTERS,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1192
                ch,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1193
                0,
7f561c08de6b Initial load
duke
parents:
diff changeset
  1194
                ch.length);
7f561c08de6b Initial load
duke
parents:
diff changeset
  1195
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
  1196
    }
25834
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 24888
diff changeset
  1197
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 24888
diff changeset
  1198
    /**
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 24888
diff changeset
  1199
     * @see org.apache.xml.serializer.Serializer#asDOM3Serializer()
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 24888
diff changeset
  1200
     */
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 24888
diff changeset
  1201
    public Object asDOM3Serializer() throws IOException
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 24888
diff changeset
  1202
    {
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 24888
diff changeset
  1203
        return m_handler.asDOM3Serializer();
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 24888
diff changeset
  1204
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
  1205
}