FileDocCategorySizeDatePackage
NamespaceFilter.javaAPI DocExample4185Thu Aug 16 16:38:06 BST 2001javaxml2

NamespaceFilter

public class NamespaceFilter extends XMLFilterImpl

NamespaceFilter will take a namespace URI and replace all occurences of that URI with a newer, supplied URI. This effectively allows on-the-fly namespace changes.

Fields Summary
private String
oldURI
The old URI, to replace
private String
newURI
The new URI, to replace the old URI with
Constructors Summary
public NamespaceFilter(XMLReader reader, String oldURI, String newURI)

This will take the XMLReader to use as a parent, as well as the URI to replace, and the URI to replace it with.

param
reader XMLReader to be this filter's parent.
param
oldURI URI to replace occurrences of.
param
newURI URI to replace with.

        super(reader);
        this.oldURI = oldURI;
        this.newURI = newURI;
    
Methods Summary
public voidendElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)

            
        // Change URI, if needed
        if (uri.equals(oldURI)) {
            super.endElement(newURI, localName, qName);
        } else {            
            super.endElement(uri, localName, qName);
        }
    
public voidstartElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)

            
        // Change URI, if needed
        if (uri.equals(oldURI)) {
            super.startElement(newURI, localName, qName, attributes);
        } else {            
            super.startElement(uri, localName, qName, attributes);
        }       
    
public voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)

            
        // Change URI, if needed
        if (uri.equals(oldURI)) {
            super.startPrefixMapping(prefix, newURI);
        } else {
            super.startPrefixMapping(prefix, uri);
        }