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