String getNamespaceURI(String prefix) { String uri = null; if (_bindings != null) { uri = _bindings.get(prefix); } if (uri == null) { uri= _parent==null ? null:(_parent.getNamespaceURI(prefix)); } return uri; }
/** * <p> * Construct a new instance with the bare minimum bindings for the * <code>xmlns</code>, <code>xml</code>, and empty prefixes. Note that the empty * prefix is bound to the empty (non-<code>null</code>) URI. * </p> */ public NamespaceStack() { _current = new Frame(); /* * As per the Namespaces in XML Errata: * http://www.w3.org/XML/xml-names-19990114-errata */ _current.declarePrefix("xmlns","http://www.w3.org/2000/xmlns/"); /* * As per the Namespaces in XML Rec: * http://www.w3.org/TR/1999/REC-xml-names-19990114 */ _current.declarePrefix("xml","http://www.w3.org/XML/1998/namespace"); /* * As per the Namespaces in XML Rec: * http://www.w3.org/TR/1999/REC-xml-names-19990114 */ _current.declarePrefix("",""); }
/** * <p> * Declare a new prefix binding. This binding will supercede a binding with the * same prefix in the same scope. As a crutch, <code>null</code> arguments may be * passed and will be interpreted as <code>""</code>. Note that binding * a non-empty prefix to an empty URI is not permitted in XML 1.0 but is not * flagged as an error by the method. * </p> * @param prefix the prefix to bind * @param uri the URI to bind it to */ public void declarePrefix(String prefix, String uri) { _current.declarePrefix(prefix==null?"":prefix, uri==null?"":uri); }
/** * <p> * Fire the events for the current frame's prefixes into a <code>ContentHandler</code>. * </p> * @param ch the target <code>ContentHandler</code> * @throws SAXException if the target method does. */ public void startPrefixMappings(ContentHandler ch) throws SAXException { _current.startPrefixMappings(ch); }
/** * <p> * Retrieve the URI bound to the supplied prefix or <code>null</code> if no URI * is bound to the supplied prefix. As a crutch, a <code>null</code> argument * may be passed and will be interpreted as the empty prefix * (<code>""</code>). * </p> * @returns the URI or <code>null</code> if no URI is bound. */ public String getNamespaceUri(String prefix) { return _current.getNamespaceURI(prefix==null?"":prefix); }
/** * <p> * Push a fresh context onto the stack. This method should be called somewhere in * the body of a <code>startElement()</code>, as it represents the namespace * resolution context for the events that occur between that event and the * corresponding <code>endElement()</code>. * </p> * @see org.xml.sax.ContentHandler */ public void pushNewContext() { _current = new Frame(_current); }
/** * <p> * Fire the events for the current frame's prefixes into a <code>ContentHandler</code>. * </p> * @param ch the target <code>ContentHandler</code>. * @throws SAXException if the target method does. */ public void endPrefixMappings(ContentHandler ch) throws SAXException { _current.endPrefixMappings(ch); }