1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 /* 19 * $Id: PrefixResolver.java 468655 2006-10-28 07:12:06Z minchau $ 20 */ 21 package org.apache.xml.utils; 22 23 /** 24 * The class that implements this interface can resolve prefixes to 25 * namespaces. Examples would include resolving the meaning of a 26 * prefix at a particular point in a document, or mapping the prefixes 27 * used in an XPath expression. 28 * @xsl.usage advanced 29 */ 30 public interface PrefixResolver 31 { 32 33 /** 34 * Given a namespace, get the corrisponding prefix. This assumes that 35 * the PrefixResolver holds its own namespace context, or is a namespace 36 * context itself. 37 * 38 * @param prefix The prefix to look up, which may be an empty string ("") for the default Namespace. 39 * 40 * @return The associated Namespace URI, or null if the prefix 41 * is undeclared in this context. 42 */ getNamespaceForPrefix(String prefix)43 String getNamespaceForPrefix(String prefix); 44 45 /** 46 * Given a namespace, get the corresponding prefix, based on the context node. 47 * 48 * @param prefix The prefix to look up, which may be an empty string ("") for the default Namespace. 49 * @param context The node context from which to look up the URI. 50 * 51 * @return The associated Namespace URI as a string, or null if the prefix 52 * is undeclared in this context. 53 */ getNamespaceForPrefix(String prefix, org.w3c.dom.Node context)54 String getNamespaceForPrefix(String prefix, org.w3c.dom.Node context); 55 56 /** 57 * Return the base identifier. 58 * 59 * @return The base identifier from where relative URIs should be absolutized, or null 60 * if the base ID is unknown. 61 * <p> 62 * CAVEAT: Note that the base URI in an XML document may vary with where 63 * you are in the document, if part of the doc's contents were brought in 64 * via an external entity reference or if mechanisms such as xml:base have 65 * been used. Unless this PrefixResolver is bound to a specific portion of 66 * the document, or has been kept up to date via some other mechanism, it 67 * may not accurately reflect that context information. 68 */ getBaseIdentifier()69 public String getBaseIdentifier(); 70 handlesNullPrefixes()71 public boolean handlesNullPrefixes(); 72 } 73