001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements. See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership. The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the  "License");
007     * you may not use this file except in compliance with the License.
008     * You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    /*
019     * $Id: PrefixResolver.java 468655 2006-10-28 07:12:06Z minchau $
020     */
021    package org.apache.xml.utils;
022    
023    /**
024     * The class that implements this interface can resolve prefixes to
025     * namespaces. Examples would include resolving the meaning of a
026     * prefix at a particular point in a document, or mapping the prefixes
027     * used in an XPath expression.
028     * @xsl.usage advanced
029     */
030    public interface PrefixResolver
031    {
032    
033      /**
034       * Given a namespace, get the corrisponding prefix.  This assumes that
035       * the PrefixResolver holds its own namespace context, or is a namespace
036       * context itself.
037       *
038       * @param prefix The prefix to look up, which may be an empty string ("") for the default Namespace.
039       *
040       * @return The associated Namespace URI, or null if the prefix
041       *         is undeclared in this context.
042       */
043      String getNamespaceForPrefix(String prefix);
044    
045      /**
046       * Given a namespace, get the corresponding prefix, based on the context node.
047       *
048       * @param prefix The prefix to look up, which may be an empty string ("") for the default Namespace.
049       * @param context The node context from which to look up the URI.
050       *
051       * @return The associated Namespace URI as a string, or null if the prefix
052       *         is undeclared in this context.
053       */
054      String getNamespaceForPrefix(String prefix, org.w3c.dom.Node context);
055    
056      /**
057       * Return the base identifier.
058       *
059       * @return The base identifier from where relative URIs should be absolutized, or null 
060       * if the base ID is unknown.
061       * <p>
062       * CAVEAT: Note that the base URI in an XML document may vary with where
063       * you are in the document, if part of the doc's contents were brought in
064       * via an external entity reference or if mechanisms such as xml:base have
065       * been used. Unless this PrefixResolver is bound to a specific portion of
066       * the document, or has been kept up to date via some other mechanism, it
067       * may not accurately reflect that context information.
068       */
069      public String getBaseIdentifier();
070      
071      public boolean handlesNullPrefixes();
072    }