jlibs.xml.sax
Class NamespaceReplacer

java.lang.Object
  extended by org.xml.sax.helpers.XMLFilterImpl
      extended by jlibs.xml.sax.NamespaceReplacer
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, XMLFilter, XMLReader

public class NamespaceReplacer
extends org.xml.sax.helpers.XMLFilterImpl

SAXDelegate that can replace namespaces specified in map

Author:
Santhosh Kumar T

Field Summary
protected  Map<String,String> new2old
           
protected  MyNamespaceSupport newNSSupport
           
protected  Map<String,String> old2new
           
protected  MyNamespaceSupport oldNSSupport
           
 
Constructor Summary
NamespaceReplacer(Map<String,String> old2new)
           
NamespaceReplacer(XMLReader xmlReader, Map<String,String> old2new)
           
 
Method Summary
 void endElement(String uri, String localName, String qName)
           
 void setFeature(String name, boolean value)
           
 void startDocument()
           
 void startElement(String uri, String localName, String qName, Attributes atts)
           
 void startPrefixMapping(String prefix, String uri)
           
protected  String translate(String namespace, Map<String,String> map)
           
protected  String translateAttribute(String namespace, Map<String,String> map)
           
protected  String translateAttribute(String qName, MyNamespaceSupport from, MyNamespaceSupport to)
           
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
characters, endDocument, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setParent, setProperty, skippedEntity, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

old2new

protected Map<String,String> old2new

new2old

protected Map<String,String> new2old

oldNSSupport

protected final MyNamespaceSupport oldNSSupport

newNSSupport

protected final MyNamespaceSupport newNSSupport
Constructor Detail

NamespaceReplacer

public NamespaceReplacer(Map<String,String> old2new)

NamespaceReplacer

public NamespaceReplacer(XMLReader xmlReader,
                         Map<String,String> old2new)
Method Detail

setFeature

public void setFeature(String name,
                       boolean value)
                throws SAXNotRecognizedException,
                       SAXNotSupportedException
Specified by:
setFeature in interface XMLReader
Overrides:
setFeature in class org.xml.sax.helpers.XMLFilterImpl
Throws:
SAXNotRecognizedException
SAXNotSupportedException

translate

protected String translate(String namespace,
                           Map<String,String> map)

translateAttribute

protected String translateAttribute(String namespace,
                                    Map<String,String> map)

startDocument

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

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class org.xml.sax.helpers.XMLFilterImpl
Throws:
SAXException

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.XMLFilterImpl
Throws:
SAXException

translateAttribute

protected String translateAttribute(String qName,
                                    MyNamespaceSupport from,
                                    MyNamespaceSupport to)

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.XMLFilterImpl
Throws:
SAXException


Copyright © 2015. All rights reserved.