FileDocCategorySizeDatePackage
ToUnknownStream.javaAPI DocJava SE 6 API38380Tue Jun 10 00:23:08 BST 2008com.sun.org.apache.xml.internal.serializer

ToUnknownStream

public final class ToUnknownStream extends SerializerBase
This class wraps another SerializationHandler. The wrapped object will either handler XML or HTML, which is not known until a little later when the first XML tag is seen. If the first tag is then the wrapped object is an HTML handler, otherwise it is an XML handler. This class effectively caches the first few calls to it then passes them on to the wrapped handler (once it exists). After that subsequent calls a simply passed directly to the wrapped handler. The user of this class doesn't know if the output is ultimatley XML or HTML. This class is not a public API, it is public because it is used within Xalan.
xsl.usage
internal

Fields Summary
private SerializationHandler
m_handler
The wrapped handler, initially XML but possibly switched to HTML
private static final String
EMPTYSTRING
A String with no characters
private boolean
m_wrapped_handler_not_initialized
true if the underlying handler (XML or HTML) is fully initialized
private String
m_firstElementPrefix
the prefix of the very first tag in the document
private String
m_firstElementName
the element name (including any prefix) of the very first tag in the document
private String
m_firstElementURI
the namespace URI associated with the first element
private String
m_firstElementLocalName
the local name (no prefix) associated with the first element
private boolean
m_firstTagNotEmitted
true if the first tag has been emitted to the wrapped handler
private Vector
m_namespaceURI
A collection of namespace URI's (only for first element). _namespacePrefix has the matching prefix for these URI's
private Vector
m_namespacePrefix
A collection of namespace Prefix (only for first element) _namespaceURI has the matching URIs for these prefix'
private boolean
m_needToCallStartDocument
true if startDocument() was called before the underlying handler was initialized
private boolean
m_setVersion_called
true if setVersion() was called before the underlying handler was initialized
private boolean
m_setDoctypeSystem_called
true if setDoctypeSystem() was called before the underlying handler was initialized
private boolean
m_setDoctypePublic_called
true if setDoctypePublic() was called before the underlying handler was initialized
private boolean
m_setMediaType_called
true if setMediaType() was called before the underlying handler was initialized
Constructors Summary
public ToUnknownStream()
Default constructor. Initially this object wraps an XML Stream object, so _handler is never null. That may change later to an HTML Stream object.


                                 
     
    
        m_handler = new ToXMLStream();
    
Methods Summary
public voidaddAttribute(java.lang.String uri, java.lang.String localName, java.lang.String rawName, java.lang.String type, java.lang.String value, boolean XSLAttribute)
Adds an attribute to the currenly open tag

param
uri the URI of a namespace
param
localName the attribute name, without prefix
param
rawName the attribute name, with prefix (if any)
param
type the type of the attribute, typically "CDATA"
param
value the value of the parameter
param
XSLAttribute true if this attribute is coming from an xsl:attribute element
see
ExtendedContentHandler#addAttribute(String, String, String, String, String)

        if (m_firstTagNotEmitted)
        {
            flush();
        }
        m_handler.addAttribute(uri, localName, rawName, type, value, XSLAttribute);
    
public voidaddAttribute(java.lang.String rawName, java.lang.String value)
Adds an attribute to the currenly open tag

param
rawName the attribute name, with prefix (if any)
param
value the value of the parameter
see
ExtendedContentHandler#addAttribute(String, String)

        if (m_firstTagNotEmitted)
        {
            flush();
        }
        m_handler.addAttribute(rawName, value);
 
    
public voidaddAttributes(org.xml.sax.Attributes atts)

see
ExtendedContentHandler#addAttributes(org.xml.sax.Attributes)

        m_handler.addAttributes(atts);
    
public voidaddUniqueAttribute(java.lang.String rawName, java.lang.String value, int flags)
Adds a unique attribute to the currenly open tag

        if (m_firstTagNotEmitted)
        {
            flush();
        }
        m_handler.addUniqueAttribute(rawName, value, flags);
 
    
public org.xml.sax.ContentHandlerasContentHandler()

see
Serializer#asContentHandler()
return
the wrapped XML or HTML handler

        /* don't return the real handler ( m_handler ) because
         * that would expose the real handler to the outside.
         * Keep m_handler private so it can be internally swapped
         * to an HTML handler.
         */
        return this;
    
public com.sun.org.apache.xml.internal.serializer.DOMSerializerasDOMSerializer()

see
Serializer#asDOMSerializer()

        return m_handler.asDOMSerializer();
    
public voidattributeDecl(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.lang.String arg4)
Pass the call on to the underlying handler

see
org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String)

        m_handler.attributeDecl(arg0, arg1, arg2, arg3, arg4);
    
public voidcharacters(java.lang.String chars)
Converts the String to a character array and calls the SAX method characters(char[],int,int);

see
ExtendedContentHandler#characters(String)

        final int length = chars.length();
        if (length > m_charsBuff.length)
        {
            m_charsBuff = new char[length*2 + 1];
        }
        chars.getChars(0, length, m_charsBuff, 0);
        this.characters(m_charsBuff, 0, length);  
    
public voidcharacters(char[] characters, int offset, int length)
Pass the call on to the underlying handler

see
org.xml.sax.ContentHandler#characters(char[], int, int)

        if (m_firstTagNotEmitted)
        {
            flush();
        }

        m_handler.characters(characters, offset, length);

    
public voidclose()

see
SerializationHandler#close()

        m_handler.close();
    
public voidcomment(java.lang.String comment)
Pass the call on to the underlying handler

see
ExtendedLexicalHandler#comment(String)

        if (m_firstTagNotEmitted && m_firstElementName != null)
        {
            emitFirstTag();
        }
        else if (m_needToCallStartDocument)
        {
            m_handler.startDocument();
            m_needToCallStartDocument = false;
        }

        m_handler.comment(comment);
    
public voidcomment(char[] ch, int start, int length)
Pass the call on to the underlying handler

see
org.xml.sax.ext.LexicalHandler#comment(char[], int, int)

        if (m_firstTagNotEmitted)
        {
            flush();
        }

        m_handler.comment(ch, start, length);
    
public voidelementDecl(java.lang.String arg0, java.lang.String arg1)
Pass the call on to the underlying handler

see
org.xml.sax.ext.DeclHandler#elementDecl(String, String)

        if (m_firstTagNotEmitted)
        {
            emitFirstTag();
        }
        m_handler.elementDecl(arg0, arg1);
    
private voidemitFirstTag()

   
        if (m_firstElementName != null)
        {
            if (m_wrapped_handler_not_initialized)
            {
                initStreamOutput();
                m_wrapped_handler_not_initialized = false;
            }
            // Output first tag
            m_handler.startElement(m_firstElementURI, null, m_firstElementName, m_attributes);
            // don't need the collected attributes of the first element anymore.
            m_attributes = null;

            // Output namespaces of first tag
            if (m_namespacePrefix != null)
            {
                final int n = m_namespacePrefix.size();
                for (int i = 0; i < n; i++)
                {
                    final String prefix =
                        (String) m_namespacePrefix.elementAt(i);
                    final String uri = (String) m_namespaceURI.elementAt(i);
                    m_handler.startPrefixMapping(prefix, uri, false);
                }
                m_namespacePrefix = null;
                m_namespaceURI = null;
            }
            m_firstTagNotEmitted = false;
        }
    
public voidendCDATA()
Pass the call on to the underlying handler

see
org.xml.sax.ext.LexicalHandler#endCDATA()


        m_handler.endCDATA();
    
public voidendDTD()
Pass the call on to the underlying handler

see
org.xml.sax.ext.LexicalHandler#endDTD()


        m_handler.endDTD();
    
public voidendDocument()
Pass the call on to the underlying handler

see
org.xml.sax.ContentHandler#endDocument()

        if (m_firstTagNotEmitted)
        {
            flush();
        }

        m_handler.endDocument();
        
    
    
public voidendElement(java.lang.String elementName)
Pass the call on to the underlying handler

see
ExtendedContentHandler#endElement(String)

        if (m_firstTagNotEmitted)
        {
            flush();
        }
        m_handler.endElement(elementName);
    
public voidendElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
Pass the call on to the underlying handler

see
org.xml.sax.ContentHandler#endElement(String, String, String)

        if (m_firstTagNotEmitted)
        {
            flush();
            if (namespaceURI == null && m_firstElementURI != null)
                namespaceURI = m_firstElementURI;


            if (localName == null && m_firstElementLocalName != null)
                localName = m_firstElementLocalName;
        }
        
        m_handler.endElement(namespaceURI, localName, qName);
    
public voidendEntity(java.lang.String name)
Pass the call on to the underlying handler

see
org.xml.sax.ext.LexicalHandler#endEntity(String)

        if (m_firstTagNotEmitted)
        {
            emitFirstTag();
        }
        m_handler.endEntity(name);
    
public voidendPrefixMapping(java.lang.String prefix)
Pass the call on to the underlying handler

see
org.xml.sax.ContentHandler#endPrefixMapping(String)

        m_handler.endPrefixMapping(prefix);
    
public voidentityReference(java.lang.String entityName)

see
ExtendedContentHandler#entityReference(java.lang.String)

        m_handler.entityReference(entityName);
    
public voidexternalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
Pass the call on to the underlying handler

see
org.xml.sax.ext.DeclHandler#externalEntityDecl(String, String, String)

        if (m_firstTagNotEmitted)
        {
            flush();
        }
        m_handler.externalEntityDecl(name, publicId, systemId);
    
protected voidfirePseudoElement(java.lang.String elementName)

        
        if (m_tracer != null) {
            StringBuffer sb = new StringBuffer();
                
            sb.append('<");
            sb.append(elementName);
            
            // convert the StringBuffer to a char array and
            // emit the trace event that these characters "might"
            // be written
            char ch[] = sb.toString().toCharArray();
            m_tracer.fireGenerateEvent(
                SerializerTrace.EVENTTYPE_OUTPUT_PSEUDO_CHARACTERS,
                ch,
                0,
                ch.length);
        }
    
private voidflush()

        try
        {
        if (m_firstTagNotEmitted)
        {
            emitFirstTag();
        }
        if (m_needToCallStartDocument)
        {
            m_handler.startDocument();
            m_needToCallStartDocument = false;
        }
        }
        catch(SAXException e)
        {
            throw new RuntimeException(e.toString());
        }
          
    
    
public voidflushPending()

see
SerializationHandler#flushPending()

 
        flush();
      
        m_handler.flushPending();
    
public java.lang.StringgetDoctypePublic()
Pass the call on to the underlying handler

see
XSLOutputAttributes#getDoctypePublic()


        return m_handler.getDoctypePublic();
    
public java.lang.StringgetDoctypeSystem()
Pass the call on to the underlying handler

see
XSLOutputAttributes#getDoctypeSystem()

        return m_handler.getDoctypeSystem();
    
public java.lang.StringgetEncoding()
Pass the call on to the underlying handler

see
XSLOutputAttributes#getEncoding()

        return m_handler.getEncoding();
    
public booleangetIndent()
Pass the call on to the underlying handler

see
XSLOutputAttributes#getIndent()

        return m_handler.getIndent();
    
public intgetIndentAmount()
Pass the call on to the underlying handler

see
XSLOutputAttributes#getIndentAmount()

        return m_handler.getIndentAmount();
    
private java.lang.StringgetLocalNameUnknown(java.lang.String value)
Utility function for calls to local-name(). Don't want to override static function on SerializerBase So added Unknown suffix to method name.

        int idx = value.lastIndexOf(':");
        if (idx >= 0)
            value = value.substring(idx + 1);
        idx = value.lastIndexOf('@");
        if (idx >= 0)
            value = value.substring(idx + 1);
        return (value);
    
public java.lang.StringgetMediaType()
Pass the call on to the underlying handler

see
XSLOutputAttributes#getMediaType()

        return m_handler.getMediaType();
    
public com.sun.org.apache.xml.internal.serializer.NamespaceMappingsgetNamespaceMappings()
Get the current namespace mappings. Simply returns the mappings of the wrapped handler.

see
ExtendedContentHandler#getNamespaceMappings()

        NamespaceMappings mappings = null;
        if (m_handler != null)
        {
            mappings = m_handler.getNamespaceMappings();
        }
        return mappings;
    
public java.lang.StringgetNamespaceURI(java.lang.String qname, boolean isElement)

see
ExtendedContentHandler#getNamespaceURI(java.lang.String, boolean)

        return m_handler.getNamespaceURI(qname, isElement);
    
public java.lang.StringgetNamespaceURIFromPrefix(java.lang.String prefix)

        return m_handler.getNamespaceURIFromPrefix(prefix);
    
public booleangetOmitXMLDeclaration()
Pass the call on to the underlying handler

see
XSLOutputAttributes#getOmitXMLDeclaration()

        return m_handler.getOmitXMLDeclaration();
    
public java.util.PropertiesgetOutputFormat()

see
Serializer#getOutputFormat()
return
the properties of the underlying handler

        return m_handler.getOutputFormat();
    
public java.io.OutputStreamgetOutputStream()

see
Serializer#getOutputStream()
return
the OutputStream of the underlying XML or HTML handler

        return m_handler.getOutputStream();
    
public java.lang.StringgetPrefix(java.lang.String namespaceURI)

see
ExtendedContentHandler#getPrefix

        return m_handler.getPrefix(namespaceURI);
    
private java.lang.StringgetPrefixPartUnknown(java.lang.String qname)
Utility function to return prefix Don't want to override static function on SerializerBase So added Unknown suffix to method name.

        final int index = qname.indexOf(':");
        return (index > 0) ? qname.substring(0, index) : EMPTYSTRING;
    
public java.lang.StringgetStandalone()
Pass the call on to the underlying handler

see
XSLOutputAttributes#getStandalone()

        return m_handler.getStandalone();
    
public javax.xml.transform.TransformergetTransformer()

        return m_handler.getTransformer();
    
public java.lang.StringgetVersion()
Pass the call on to the underlying handler

see
XSLOutputAttributes#getVersion()

        return m_handler.getVersion();
    
public java.io.WritergetWriter()

see
Serializer#getWriter()
return
the Writer of the underlying XML or HTML handler

        return m_handler.getWriter();
    
public voidignorableWhitespace(char[] ch, int start, int length)
Pass the call on to the underlying handler

see
org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)

        if (m_firstTagNotEmitted)
        {
            flush();
        }
        m_handler.ignorableWhitespace(ch, start, length);
    
private voidinitStreamOutput()
Initialize the wrapped output stream (XML or HTML). If the stream handler should be HTML, then replace the XML handler with an HTML handler. After than send the starting method calls that were cached to the wrapped handler.


        // Try to rule out if this is an not to be an HTML document based on prefix
        boolean firstElementIsHTML = isFirstElemHTML();

        if (firstElementIsHTML)
        {
            // create an HTML output handler, and initialize it

            // keep a reference to the old handler, ... it will soon be gone
            SerializationHandler oldHandler = m_handler;

            /* We have to make sure we get an output properties with the proper
             * defaults for the HTML method.  The easiest way to do this is to
             * have the OutputProperties class do it.
             */

            Properties htmlProperties =
                OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
            Serializer serializer =
                SerializerFactory.getSerializer(htmlProperties);

            // The factory should be returning a ToStream
            // Don't know what to do if it doesn't
            // i.e. the user has over-ridden the content-handler property
            // for html
            m_handler = (SerializationHandler) serializer;
            //m_handler = new ToHTMLStream();

            Writer writer = oldHandler.getWriter();

            if (null != writer)
                m_handler.setWriter(writer);
            else
            {
                OutputStream os = oldHandler.getOutputStream();

                if (null != os)
                    m_handler.setOutputStream(os);
            }

            // need to copy things from the old handler to the new one here

            //            if (_setVersion_called)
            //            {
            m_handler.setVersion(oldHandler.getVersion());
            //            }
            //            if (_setDoctypeSystem_called)
            //            {
            m_handler.setDoctypeSystem(oldHandler.getDoctypeSystem());
            //            }
            //            if (_setDoctypePublic_called)
            //            {
            m_handler.setDoctypePublic(oldHandler.getDoctypePublic());
            //            }
            //            if (_setMediaType_called)
            //            {
            m_handler.setMediaType(oldHandler.getMediaType());
            //            }
            
            m_handler.setTransformer(oldHandler.getTransformer());
        }

        /* Now that we have a real wrapped handler (XML or HTML) lets
         * pass any cached calls to it
         */
        // Call startDocument() if necessary
        if (m_needToCallStartDocument)
        {
            m_handler.startDocument();
            m_needToCallStartDocument = false;
        }

        // the wrapped handler is now fully initialized
        m_wrapped_handler_not_initialized = false;
    
public voidinternalEntityDecl(java.lang.String arg0, java.lang.String arg1)
Pass the call on to the underlying handler

see
org.xml.sax.ext.DeclHandler#internalEntityDecl(String, String)

        if (m_firstTagNotEmitted)
        {
            flush();
        }
        m_handler.internalEntityDecl(arg0, arg1);
    
private booleanisFirstElemHTML()
Determine if the firts element in the document is or This uses the cached first element name, first element prefix and the cached namespaces from previous method calls

return
true if the first element is an opening tag

        boolean isHTML;

        // is the first tag html, not considering the prefix ?
        isHTML =
            getLocalNameUnknown(m_firstElementName).equalsIgnoreCase("html");

        // Try to rule out if this is not to be an HTML document based on URI
        if (isHTML
            && m_firstElementURI != null
            && !EMPTYSTRING.equals(m_firstElementURI))
        {
            // the <html> element has a non-trivial namespace
            isHTML = false;
        }
        // Try to rule out if this is an not to be an HTML document based on prefix
        if (isHTML && m_namespacePrefix != null)
        {
            /* the first element has a name of "html", but lets check the prefix.
             * If the prefix points to a namespace with a URL that is not ""
             * then the doecument doesn't start with an <html> tag, and isn't html
             */
            final int max = m_namespacePrefix.size();
            for (int i = 0; i < max; i++)
            {
                final String prefix = (String) m_namespacePrefix.elementAt(i);
                final String uri = (String) m_namespaceURI.elementAt(i);

                if (m_firstElementPrefix != null
                    && m_firstElementPrefix.equals(prefix)
                    && !EMPTYSTRING.equals(uri))
                {
                    // The first element has a prefix, so it can't be <html>
                    isHTML = false;
                    break;
                }
            }

        }
        return isHTML;
    
public voidnamespaceAfterStartElement(java.lang.String prefix, java.lang.String uri)
This method is used when a prefix/uri namespace mapping is indicated after the element was started with a startElement() and before and endElement(). startPrefixMapping(prefix,uri) would be used before the startElement() call.

param
uri the URI of the namespace
param
prefix the prefix associated with the given URI.
see
ExtendedContentHandler#namespaceAfterStartElement(String, String)

  
        // hack for XSLTC with finding URI for default namespace
        if (m_firstTagNotEmitted && m_firstElementURI == null && m_firstElementName != null)
        {
            String prefix1 = getPrefixPart(m_firstElementName);
            if (prefix1 == null && EMPTYSTRING.equals(prefix))
            {
                // the elements URI is not known yet, and it
                // doesn't have a prefix, and we are currently
                // setting the uri for prefix "", so we have
                // the uri for the element... lets remember it
                m_firstElementURI = uri;
            }
        }         
        startPrefixMapping(prefix,uri, false);          
    
public voidprocessingInstruction(java.lang.String target, java.lang.String data)
Pass the call on to the underlying handler

see
org.xml.sax.ContentHandler#processingInstruction(String, String)

          if (m_firstTagNotEmitted)
        {
            flush();
        }

        m_handler.processingInstruction(target, data);
    
public booleanreset()
passes the call on to the underlying HTML or XML handler

see
Serializer#reset()
return
???

        return m_handler.reset();
    
public voidserialize(org.w3c.dom.Node node)
Converts the DOM node to output

param
node the DOM node to transform to output
see
DOMSerializer#serialize(Node)

        if (m_firstTagNotEmitted)
        {
            flush();
        }
        m_handler.serialize(node);
    
public voidsetCdataSectionElements(java.util.Vector URI_and_localNames)

param
URI_and_localNames Vector a list of pairs of URI/localName specified in the cdata-section-elements attribute.
see
SerializationHandler#setCdataSectionElements(java.util.Vector)

        m_handler.setCdataSectionElements(URI_and_localNames);
    
public voidsetContentHandler(org.xml.sax.ContentHandler ch)

see
SerializationHandler#setContentHandler(org.xml.sax.ContentHandler)

        m_handler.setContentHandler(ch);
    
public voidsetDoctype(java.lang.String system, java.lang.String pub)

see
XSLOutputAttributes#setDoctype(String, String)

        m_handler.setDoctypePublic(pub);
        m_handler.setDoctypeSystem(system);
    
public voidsetDoctypePublic(java.lang.String doctype)
Set the doctype in the underlying XML handler. Remember that this method was called, just in case we need to transfer this doctype to an HTML handler

param
doctype the public doctype to set
see
XSLOutputAttributes#setDoctypePublic(String)

        m_handler.setDoctypePublic(doctype);
        m_setDoctypePublic_called = true;
    
public voidsetDoctypeSystem(java.lang.String doctype)
Set the doctype in the underlying XML handler. Remember that this method was called, just in case we need to transfer this doctype to an HTML handler

param
doctype the system doctype to set
see
XSLOutputAttributes#setDoctypeSystem(String)

        m_handler.setDoctypeSystem(doctype);
        m_setDoctypeSystem_called = true;
    
public voidsetDocumentLocator(org.xml.sax.Locator locator)
Pass the call on to the underlying handler

see
org.xml.sax.ContentHandler#setDocumentLocator(Locator)

        super.setDocumentLocator(locator);
        m_handler.setDocumentLocator(locator);
    
public voidsetEncoding(java.lang.String encoding)
Pass the call on to the underlying handler

see
XSLOutputAttributes#setEncoding(String)

        m_handler.setEncoding(encoding);
    
public booleansetEscaping(boolean escape)

see
SerializationHandler#setEscaping(boolean)

        return m_handler.setEscaping(escape);
    
public voidsetIndent(boolean indent)
Pass the call on to the underlying handler

see
XSLOutputAttributes#setIndent(boolean)

        m_handler.setIndent(indent);
    
public voidsetIndentAmount(int value)
Pass the call on to the underlying handler

        m_handler.setIndentAmount(value);
    
public voidsetMediaType(java.lang.String mediaType)

see
XSLOutputAttributes#setMediaType(String)

        m_handler.setMediaType(mediaType);
        m_setMediaType_called = true;
    
public voidsetOmitXMLDeclaration(boolean b)
Pass the call on to the underlying handler

see
XSLOutputAttributes#setOmitXMLDeclaration(boolean)

        m_handler.setOmitXMLDeclaration(b);
    
public voidsetOutputFormat(java.util.Properties format)
Set the properties of the handler

param
format the output properties to set
see
Serializer#setOutputFormat(Properties)

        m_handler.setOutputFormat(format);
    
public voidsetOutputStream(java.io.OutputStream output)
Sets the output stream to write to

param
output the OutputStream to write to
see
Serializer#setOutputStream(OutputStream)

        m_handler.setOutputStream(output);
    
public voidsetSourceLocator(javax.xml.transform.SourceLocator locator)
This method is used to set the source locator, which might be used to generated an error message.

param
locator the source locator
see
ExtendedContentHandler#setSourceLocator(javax.xml.transform.SourceLocator)

        m_handler.setSourceLocator(locator);
    
public voidsetStandalone(java.lang.String standalone)
Pass the call on to the underlying handler

see
XSLOutputAttributes#setStandalone(String)

        m_handler.setStandalone(standalone);
    
public voidsetTransformer(javax.xml.transform.Transformer t)

       
        m_handler.setTransformer(t);
        if ((t instanceof SerializerTrace) &&
            (((SerializerTrace) t).hasTraceListeners())) {
           m_tracer = (SerializerTrace) t;
        } else {
           m_tracer = null;
        }        
    
public voidsetVersion(java.lang.String version)
This method cannot be cached because default is different in HTML and XML (we need more than a boolean).

        m_handler.setVersion(version);

        // Cache call to setVersion()
        //       super.setVersion(version);
        m_setVersion_called = true;
    
public voidsetWriter(java.io.Writer writer)
Sets the writer to write to

param
writer the writer to write to
see
Serializer#setWriter(Writer)

        m_handler.setWriter(writer);
    
public voidskippedEntity(java.lang.String name)
Pass the call on to the underlying handler

see
org.xml.sax.ContentHandler#skippedEntity(String)

        m_handler.skippedEntity(name);
    
public voidstartCDATA()
Pass the call on to the underlying handler

see
org.xml.sax.ext.LexicalHandler#startCDATA()

        m_handler.startCDATA();
    
public voidstartDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
Pass the call on to the underlying handler

see
org.xml.sax.ext.LexicalHandler#startDTD(String, String, String)

        m_handler.startDTD(name, publicId, systemId);
    
public voidstartDocument()

see
org.xml.sax.ContentHandler#startDocument()

        m_needToCallStartDocument = true;
    
public voidstartElement(java.lang.String qName)

        this.startElement(null, null, qName, null);
    
public voidstartElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)

        this.startElement(namespaceURI, localName, qName, null);
    
public voidstartElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String elementName, org.xml.sax.Attributes atts)

        
        if (m_needToCallSetDocumentInfo){
            super.setDocumentInfo();
            m_needToCallSetDocumentInfo = false;
        }
        
        /* we are notified of the start of an element */
        if (m_firstTagNotEmitted)
        {
            /* we have not yet sent the first element on its way */
            if (m_firstElementName != null) 
            {
                /* this is not the first element, but a later one.
                 * But we have the old element pending, so flush it out,
                 * then send this one on its way. 
                 */
                flush();
                m_handler.startElement(namespaceURI, localName, elementName,  atts);                
            }
            else
            {
                /* this is the very first element that we have seen, 
                 * so save it for flushing later.  We may yet get to know its
                 * URI due to added attributes.
                 */
                 
                m_wrapped_handler_not_initialized = true;
                m_firstElementName = elementName;
                
                // null if not known
                m_firstElementPrefix = getPrefixPartUnknown(elementName);
                
                // null if not known
                m_firstElementURI = namespaceURI;
                
                // null if not known
                m_firstElementLocalName = localName;

                if (m_tracer != null)
                    firePseudoElement(elementName);
                    
                /* we don't want to call our own addAttributes, which
                 * merely delegates to the wrapped handler, but we want to
                 * add these attributes to m_attributes. So me must call super.
                 * addAttributes() In this case m_attributes is only used for the
                 * first element, after that this class totally delegates to the
                 * wrapped handler which is either XML or HTML.
                 */
                if (atts != null)   
                    super.addAttributes(atts);
                
                // if there are attributes, then lets make the flush()
                // call the startElement on the handler and send the
                // attributes on their way.
                if (atts != null)   
                    flush();
                
            }
        }
        else
        {
            // this is not the first element, but a later one, so just
            // send it on its way.
            m_handler.startElement(namespaceURI, localName, elementName,  atts);
        }
    
public voidstartEntity(java.lang.String name)
Pass the call on to the underlying handler

see
org.xml.sax.ext.LexicalHandler#startEntity(String)

        m_handler.startEntity(name);
    
public voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)

see
org.xml.sax.ContentHandler#startPrefixMapping(String, String)
param
prefix The prefix that maps to the URI
param
uri The URI for the namespace

        this.startPrefixMapping(prefix,uri, true);
    
public booleanstartPrefixMapping(java.lang.String prefix, java.lang.String uri, boolean shouldFlush)

        boolean pushed = false;
        if (m_firstTagNotEmitted)
        {
            if (m_firstElementName != null && shouldFlush)
            {
                /* we've already seen a startElement, and this is a prefix mapping
                 * for the up coming element, so flush the old element
                 * then send this event on its way.
                 */
                flush();
                pushed = m_handler.startPrefixMapping(prefix, uri, shouldFlush);
            } 
            else 
            {           
                if (m_namespacePrefix == null)
                {
                    m_namespacePrefix = new Vector();
                    m_namespaceURI = new Vector();
                }
                m_namespacePrefix.addElement(prefix);
                m_namespaceURI.addElement(uri);
            
                if (m_firstElementURI == null)
                {
                    if (prefix.equals(m_firstElementPrefix))
                        m_firstElementURI = uri;
                }
            }

        }
        else
        {
           pushed = m_handler.startPrefixMapping(prefix, uri, shouldFlush);
        }
        return pushed;