org.apache.cocoon.serialization
Class AbstractTextSerializer.NamespaceAsAttributes

java.lang.Object
  extended byorg.apache.cocoon.util.AbstractLogEnabled
      extended byorg.apache.cocoon.xml.AbstractXMLProducer
          extended byorg.apache.cocoon.xml.AbstractXMLPipe
              extended byorg.apache.cocoon.serialization.AbstractTextSerializer.NamespaceAsAttributes
All Implemented Interfaces:
ContentHandler, LexicalHandler, Poolable, Recyclable, XMLConsumer, org.apache.cocoon.xml.XMLConsumer, org.apache.cocoon.xml.XMLPipe, org.apache.cocoon.xml.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.


Field Summary
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Constructor Summary
AbstractTextSerializer.NamespaceAsAttributes()
           
 
Method Summary
 void endDocument()
          Receive notification of the end of a document.
 void endElement(String eltUri, String eltLocalName, String eltQName)
          Receive notification of the end of an element.
 void endPrefixMapping(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(String eltUri, String eltLocalName, String eltQName, Attributes attrs)
          Ensure all namespace declarations are present as xmlns: attributes and add those needed before calling superclass.
 void startPrefixMapping(String prefix, 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.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
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 SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the beginning of a document.

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class AbstractXMLPipe
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Track mappings to be able to add xmlns: attributes in startElement().

Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class AbstractXMLPipe
Parameters:
prefix - The Namespace prefix being declared.
uri - The Namespace URI the prefix is mapped to.
Throws:
SAXException

startElement

public void startElement(String eltUri,
                         String eltLocalName,
                         String eltQName,
                         Attributes attrs)
                  throws 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().

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class AbstractXMLPipe
Parameters:
eltUri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
eltLocalName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
eltQName - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.
attrs - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
SAXException

endElement

public void endElement(String eltUri,
                       String eltLocalName,
                       String eltQName)
                throws SAXException
Receive notification of the end of an element. Try to restore the element qName.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class AbstractXMLPipe
Parameters:
eltUri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
eltLocalName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
eltQName - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
End the scope of a prefix-URI mapping: remove entry from mapping tables.

Specified by:
endPrefixMapping in interface ContentHandler
Overrides:
endPrefixMapping in class AbstractXMLPipe
Parameters:
prefix - The prefix that was being mapping.
Throws:
SAXException

endDocument

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

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class AbstractXMLPipe
Throws:
SAXException


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.