| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.om; |
| 9 | |
| 10 | import java.util.Iterator; |
| 11 | |
| 12 | /** |
| 13 | * Abstract class that supports lookup of a lexical QName to get the expanded QName. |
| 14 | */ |
| 15 | |
| 16 | public interface NamespaceResolver { |
| 17 | |
| 18 | /** |
| 19 | * Get the namespace URI corresponding to a given prefix. Return null |
| 20 | * if the prefix is not in scope. |
| 21 | * |
| 22 | * @param prefix the namespace prefix. May be the zero-length string, indicating |
| 23 | * that there is no prefix. This indicates either the default namespace or the |
| 24 | * null namespace, depending on the value of useDefault. |
| 25 | * @param useDefault true if the default namespace is to be used when the |
| 26 | * prefix is "". If false, the method returns "" when the prefix is "". The default |
| 27 | * namespace is a property of the NamespaceResolver; in general it corresponds to |
| 28 | * the "default namespace for elements and types", but that cannot be assumed. |
| 29 | * @return the uri for the namespace, or null if the prefix is not in scope. |
| 30 | * The "null namespace" is represented by the pseudo-URI "". |
| 31 | */ |
| 32 | |
| 33 | /*@Nullable*/ |
| 34 | String getURIForPrefix(String prefix, boolean useDefault); |
| 35 | |
| 36 | /** |
| 37 | * Get an iterator over all the prefixes declared in this namespace context. This will include |
| 38 | * the default namespace (prefix="") and the XML namespace where appropriate |
| 39 | * |
| 40 | * @return an iterator over all the prefixes for which a namespace binding exists, including |
| 41 | * the zero-length string to represent the null/absent prefix if it is bound |
| 42 | */ |
| 43 | |
| 44 | Iterator<String> iteratePrefixes(); |
| 45 | |
| 46 | } |
| 47 |