org.apache.cocoon.serialization
Class AbstractTextSerializer.NamespaceAsAttributes

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.xml.AbstractXMLProducer
              |
              +--org.apache.cocoon.xml.AbstractXMLPipe
                    |
                    +--org.apache.cocoon.serialization.AbstractTextSerializer.NamespaceAsAttributes
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, XMLConsumer, XMLPipe, XMLProducer
Enclosing class:
AbstractTextSerializer

public static class AbstractTextSerializer.NamespaceAsAttributes
extends AbstractXMLPipe

A pipe that ensures that all namespace prefixes are also present as 'xmlns:' attributes. This used to circumvent Xalan's serialization behaviour which is to ignore namespaces if they're not present as 'xmlns:xxx' attributes.


Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, lexicalHandler, xmlConsumer
 
Constructor Summary
AbstractTextSerializer.NamespaceAsAttributes()
           
 
Method Summary
 void endDocument()
          Receive notification of the end of a document.
 void endElement(java.lang.String eltUri, java.lang.String eltLocalName, java.lang.String eltQName)
          Receive notification of the end of an element.
 void endPrefixMapping(java.lang.String prefix)
          End the scope of a prefix-URI mapping: remove entry from mapping tables.
 void startDocument()
          Receive notification of the beginning of a document.
 void startElement(java.lang.String eltUri, java.lang.String eltLocalName, java.lang.String eltQName, org.xml.sax.Attributes attrs)
          Ensure all namespace declarations are present as xmlns: attributes and add those needed before calling superclass.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Track mappings to be able to add xmlns: attributes in startElement().
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDTD, endEntity, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDTD, startEntity
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
recycle, setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Constructor Detail

AbstractTextSerializer.NamespaceAsAttributes

public AbstractTextSerializer.NamespaceAsAttributes()
Method Detail

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the beginning of a document.
Overrides:
startDocument in class AbstractXMLPipe

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Track mappings to be able to add xmlns: attributes in startElement().
Overrides:
startPrefixMapping in class AbstractXMLPipe
Following copied from class: org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
prefix - The Namespace prefix being declared.
uri - The Namespace URI the prefix is mapped to.

startElement

public void startElement(java.lang.String eltUri,
                         java.lang.String eltLocalName,
                         java.lang.String eltQName,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
Ensure all namespace declarations are present as xmlns: attributes and add those needed before calling superclass. This is a workaround for a Xalan bug (at least in version 2.0.1) : org.apache.xalan.serialize.SerializerToXML ignores start/endPrefixMapping().
Overrides:
startElement in class AbstractXMLPipe
Following copied from class: org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
loc - The local name (without prefix), or the empty string if Namespace processing is not being performed.
raw - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.
a - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.

endElement

public void endElement(java.lang.String eltUri,
                       java.lang.String eltLocalName,
                       java.lang.String eltQName)
                throws org.xml.sax.SAXException
Receive notification of the end of an element. Try to restore the element qName.
Overrides:
endElement in class AbstractXMLPipe
Following copied from class: org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
loc - The local name (without prefix), or the empty string if Namespace processing is not being performed.
raw - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
End the scope of a prefix-URI mapping: remove entry from mapping tables.
Overrides:
endPrefixMapping in class AbstractXMLPipe
Following copied from class: org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
prefix - The prefix that was being mapping.

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the end of a document.
Overrides:
endDocument in class AbstractXMLPipe


Copyright � 1999-2002 Apache Software Foundation. All Rights Reserved.