public String getPrefix(String uri) throws SAXException {
            String prefix = namespaces.get(uri);
            if (prefix != null) {
                return prefix;
            } else if (parent != null) {
                return parent.getPrefix(uri);
            } else if (uri == null || uri.isEmpty()) {
                return "";
            } else {
                throw new SAXException("Namespace " + uri + " not declared");
            }
        }
Writes the given characters with XML meta characters escaped.

@param ch        character array
@param from      start position in the array
@param to        end position in the array
@param attribute whether the characters should be escaped as
                 an attribute value or normal character content
@throws SAXException if the characters could not be written
tika-core/src/main/java/org/apache/tika/sax/ToXMLContentHandler.java