org.apache.felix.scrplugin.xml
Class IOUtils.NamespaceAsAttributes

java.lang.Object
  extended by org.apache.felix.scrplugin.xml.IOUtils.NamespaceAsAttributes
All Implemented Interfaces:
org.xml.sax.ContentHandler
Enclosing class:
IOUtils

public static class IOUtils.NamespaceAsAttributes
extends java.lang.Object
implements org.xml.sax.ContentHandler

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.


Constructor Summary
IOUtils.NamespaceAsAttributes(org.xml.sax.ContentHandler ch)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endDocument()
           
 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 ignorableWhitespace(char[] ch, int start, int length)
           
 void processingInstruction(java.lang.String target, java.lang.String data)
           
 void setDocumentLocator(org.xml.sax.Locator locator)
           
 void skippedEntity(java.lang.String name)
           
 void startDocument()
           
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOUtils.NamespaceAsAttributes

public IOUtils.NamespaceAsAttributes(org.xml.sax.ContentHandler ch)
Method Detail

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Specified by:
startDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

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().

Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

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().

Specified by:
startElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

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.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

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.

Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Specified by:
endDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.endDocument()

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Specified by:
characters in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.characters(char[], int, int)

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.ignorableWhitespace(char[], int, int)

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.processingInstruction(java.lang.String, java.lang.String)

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
See Also:
ContentHandler.setDocumentLocator(org.xml.sax.Locator)

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.skippedEntity(java.lang.String)