Skip to content

Package: NamespaceContextEx

NamespaceContextEx

Coverage

1: /*
2: * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Distribution License v. 1.0, which is available at
6: * http://www.eclipse.org/org/documents/edl-v10.php.
7: *
8: * SPDX-License-Identifier: BSD-3-Clause
9: */
10:
11: package org.jvnet.staxex;
12:
13: import javax.xml.namespace.NamespaceContext;
14: import java.util.Iterator;
15:
16: /**
17: * Extended {@link NamespaceContext}.
18: *
19: * @author Kohsuke Kawaguchi
20: * @author Paul Sandoz
21: */
22: public interface NamespaceContextEx extends NamespaceContext, Iterable<NamespaceContextEx.Binding> {
23:
24: /**
25: * Iterates all the in-scope namespace bindings.
26: *
27: * <p>
28: * This method enumerates all the active in-scope namespace bindings.
29: * This does not include implicit bindings, such as
30: * {@code "xml"->"http://www.w3.org/XML/1998/namespace"}
31: * or {@code ""->""} (the implicit default namespace URI.)
32: *
33: * <p>
34: * The returned iterator may not include the same prefix more than once.
35: * For example, the returned iterator may only contain {@code f=ns2}
36: * if the document is as follows and this method is used at the bar element.
37: *
38: * <pre>{@code
39: * <foo xmlns:f='ns1'>
40: * <bar xmlns:f='ns2'>
41: * ...
42: * }</pre>
43: *
44: * <p>
45: * The iteration may be done in no particular order.
46: *
47: * @return
48: * may return an empty iterator, but never null.
49: */
50: @Override
51: Iterator<Binding> iterator();
52:
53: /**
54: * Prefix to namespace URI binding.
55: */
56: interface Binding {
57: /**
58: * Gets the prefix.
59: *
60: * <p>
61: * The default namespace URI is represented by using an
62: * empty string "", not null.
63: *
64: * @return
65: * never null. String like "foo", "ns12", or "".
66: */
67: String getPrefix();
68:
69: /**
70: * Gets the namespace URI.
71: *
72: * <p>
73: * The empty namespace URI is represented by using
74: * an empty string "", not null.
75: *
76: * @return
77: * never null. String like "http://www.w3.org/XML/1998/namespace",
78: * "urn:oasis:names:specification:docbook:dtd:xml:4.1.2", or "".
79: */
80: String getNamespaceURI();
81: }
82: }