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