14c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/* 24c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one 34c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or more contributor license agreements. See the NOTICE file 44c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed with this work for additional information 54c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * regarding copyright ownership. The ASF licenses this file 64c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * to you under the Apache License, Version 2.0 (the "License"); 74c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * you may not use this file except in compliance with the License. 84c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * You may obtain a copy of the License at 94c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Unless required by applicable law or agreed to in writing, software 134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * See the License for the specific language governing permissions and 164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * limitations under the License. 174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/* 194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * $Id: PrefixResolver.java 468655 2006-10-28 07:12:06Z minchau $ 204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpackage org.apache.xml.utils; 224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/** 244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * The class that implements this interface can resolve prefixes to 254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * namespaces. Examples would include resolving the meaning of a 264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * prefix at a particular point in a document, or mapping the prefixes 274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * used in an XPath expression. 284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @xsl.usage advanced 294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpublic interface PrefixResolver 314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson{ 324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a namespace, get the corrisponding prefix. This assumes that 354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the PrefixResolver holds its own namespace context, or is a namespace 364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * context itself. 374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param prefix The prefix to look up, which may be an empty string ("") for the default Namespace. 394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return The associated Namespace URI, or null if the prefix 414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * is undeclared in this context. 424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String getNamespaceForPrefix(String prefix); 444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a namespace, get the corresponding prefix, based on the context node. 474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param prefix The prefix to look up, which may be an empty string ("") for the default Namespace. 494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param context The node context from which to look up the URI. 504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return The associated Namespace URI as a string, or null if the prefix 524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * is undeclared in this context. 534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String getNamespaceForPrefix(String prefix, org.w3c.dom.Node context); 554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return the base identifier. 584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return The base identifier from where relative URIs should be absolutized, or null 604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * if the base ID is unknown. 614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * CAVEAT: Note that the base URI in an XML document may vary with where 634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * you are in the document, if part of the doc's contents were brought in 644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * via an external entity reference or if mechanisms such as xml:base have 654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * been used. Unless this PrefixResolver is bound to a specific portion of 664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the document, or has been kept up to date via some other mechanism, it 674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * may not accurately reflect that context information. 684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getBaseIdentifier(); 704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public boolean handlesNullPrefixes(); 724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson} 73