org.apache.cocoon.xml
Class RedundantNamespacesFilter

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.xml.RedundantNamespacesFilter
All Implemented Interfaces:
ContentHandler, LexicalHandler, Poolable, Recyclable, XMLConsumer, org.apache.cocoon.xml.XMLConsumer, org.apache.cocoon.xml.XMLPipe, org.apache.cocoon.xml.XMLProducer

public class RedundantNamespacesFilter
extends org.apache.cocoon.xml.AbstractXMLPipe

A SAX filter that strips out redundant namespace declarations.

It handles both duplicate declarations (i.e. a namespace already declared by a parent element) and empty namespaces scopes (i.e. start/stopPrefixMapping with no element inbetween) that can be produced by some components (e.g. JXTG or BrowserUpdateTransformer). Such empty scopes confuse the Xalan serializer which then produces weird namespace declarations (xmlns:%@$#^@#="%@$#^@#").

This is a the most simple use of NamespacesTable.

Version:
$Id: RedundantNamespacesFilter.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Constructor Summary
RedundantNamespacesFilter()
          No-arg constructor.
RedundantNamespacesFilter(org.apache.cocoon.xml.XMLConsumer consumer)
          Creates a filter directly linked to its consumer
 
Method Summary
 void endElement(String uri, String loc, String raw)
           
 void endPrefixMapping(String prefix)
           
 void startElement(String uri, String loc, String raw, Attributes a)
           
 void startPrefixMapping(String prefix, String uri)
           
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDocument, endDTD, endEntity, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDocument, 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

RedundantNamespacesFilter

public RedundantNamespacesFilter()
No-arg constructor. Requires an explicit call to setConsumer().


RedundantNamespacesFilter

public RedundantNamespacesFilter(org.apache.cocoon.xml.XMLConsumer consumer)
Creates a filter directly linked to its consumer

Parameters:
consumer - the SAX stream consumer
Method Detail

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Throws:
SAXException

startElement

public void startElement(String uri,
                         String loc,
                         String raw,
                         Attributes a)
                  throws SAXException
Throws:
SAXException

endElement

public void endElement(String uri,
                       String loc,
                       String raw)
                throws SAXException
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Throws:
SAXException


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