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