01: /*
02: * The contents of this file are subject to the
03: * Mozilla Public License Version 1.1 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
09: * See the License for the specific language governing rights and
10: * limitations under the License.
11: *
12: * The Initial Developer of the Original Code is Simulacra Media Ltd.
13: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14: *
15: * All Rights Reserved.
16: *
17: * Contributor(s):
18: */
19: package org.openharmonise.commons.xml.namespace;
20:
21: import org.w3c.dom.Node;
22:
23: /**
24: * Defines the interface for an XML namespace resolver for looking up namespace/prefix
25: * combinations.
26: *
27: * @author Matthew Large
28: * @version $Revision: 1.1 $
29: */
30: public interface NamespaceResolver {
31:
32: /**
33: * Stores the specified namespace/prefix pair if the prefix is not already stored.
34: * If the prefix is already stored then a NamespaceClashException is thrown.
35: *
36: * @param sURI Namespace URI
37: * @param sPrefix Namespace prefix
38: * @throws NamespaceClashException If the prefix already exists
39: */
40: public void addNamespace(String sURI, String sPrefix)
41: throws NamespaceClashException;
42:
43: /**
44: * Removes the specified namespace from the resolver if it exists.
45: *
46: * @param sURI Namespace URI
47: */
48: public void removeNamespace(String sURI);
49:
50: /**
51: * Returns the namespace URI that matches the supplied prefix.
52: *
53: * @param sPrefix Namespace prefix
54: * @return Namespace URI, null if none found
55: */
56: public String getNamespaceByPrefix(String sPrefix);
57:
58: /**
59: * Returns the namespace prefix that matches the supplied URI. If the namespace is associated
60: * to more than one prefix then the first found prefix is returned.
61: * If no namespace is found then a new prefix is generated, which does not clash
62: * with any stored prefix, stored and returned.
63: *
64: * @param sURI Namespace URI
65: * @return Namespace prefix
66: */
67: public String getPrefixByNamespace(String sURI);
68:
69: /**
70: * Returns the namespace prefix that matches the namespace URI of the supplied Node.
71: * If the Node does not have a namespace URI assigned to it null will be returned.
72: * If the namespace is associated
73: * with more than one prefix then the first found prefix is returned.
74: * If no namespace is found then a new prefix is generated, which does not clash
75: * with any stored prefix, stored and returned.
76: *
77: * @param node DOM Node to be checked
78: * @return Namespace prefix or null if the Node does not have a namespace URI assigned.
79: */
80: public String getPrefixByNode(Node node)
81: throws NamespaceClashException;
82:
83: }
|