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