1 16 package org.apache.commons.jelly.parser; 17 18 import org.xml.sax.Attributes ; 19 import org.xml.sax.SAXException ; 20 import org.xml.sax.XMLReader ; 21 import org.xml.sax.helpers.XMLFilterImpl ; 22 23 30 public class DefaultNamespaceFilter extends XMLFilterImpl { 31 32 protected String uriDefault = null; 33 34 41 public DefaultNamespaceFilter(String defaultNamespace, XMLReader reader) { 42 super(reader); 43 this.uriDefault = defaultNamespace; 44 } 45 46 53 public void startPrefixMapping(java.lang.String prefix, 54 java.lang.String uri) 55 throws SAXException { 56 57 if (uri.equals("")) { 58 super.startPrefixMapping(prefix,this.uriDefault); 59 } else { 60 super.startPrefixMapping(prefix,uri); 61 } 62 } 63 64 73 public void startElement(java.lang.String uri, 74 java.lang.String localName, 75 java.lang.String qName, 76 Attributes atts) 77 throws SAXException { 78 79 if (uri.equals("")) { 80 super.startElement(this.uriDefault,localName,qName,atts); 81 } else { 82 super.startElement(uri,localName,qName,atts); 83 } 84 85 } 86 87 96 public void endElement(String namespaceURI, String localName, String qName) 97 throws SAXException { 98 if (namespaceURI.equals("")) { 99 super.endElement(this.uriDefault,localName,qName); 100 } else { 101 super.endElement(namespaceURI,localName,qName); 102 } 103 } 104 } | Popular Tags |