71 * @see javax.xml.XMLConstants 72 * javax.xml.XMLConstants for declarations of common XML values 73 * @see <a href="http://www.w3.org/TR/xmlschema-2/#QName"> 74 * XML Schema Part2: Datatypes</a> 75 * @see <a href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames"> 76 * Namespaces in XML</a> 77 * @see <a href="http://www.w3.org/XML/xml-names-19990114-errata"> 78 * Namespaces in XML Errata</a> 79 * @since 1.5 80 */ 81 82 public interface NamespaceContext { 83 84 /** 85 * Get Namespace URI bound to a prefix in the current scope. 86 * 87 * <p>When requesting a Namespace URI by prefix, the following 88 * table describes the returned Namespace URI value for all 89 * possible prefix values: 90 * 91 * <table border="2" rules="all" cellpadding="4"> 92 * <thead> 93 * <tr> 94 * <td align="center" colspan="2"> 95 * {@code getNamespaceURI(prefix)} 96 * return value for specified prefixes 97 * </td> 98 * </tr> 99 * <tr> 100 * <td>prefix parameter</td> 101 * <td>Namespace URI return value</td> 102 * </tr> 103 * </thead> 104 * <tbody> 105 * <tr> 106 * <td>{@code DEFAULT_NS_PREFIX} ("")</td> 107 * <td>default Namespace URI in the current scope or 108 * <code> {@link 109 * javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI("")} 110 * </code> 111 * when there is no default Namespace URI in the current scope</td> 112 * </tr> 113 * <tr> 114 * <td>bound prefix</td> 115 * <td>Namespace URI bound to prefix in current scope</td> 116 * </tr> 117 * <tr> 118 * <td>unbound prefix</td> 119 * <td> 120 * <code> {@link 121 * javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI("")} 141 * 142 * @param prefix prefix to look up 143 * 144 * @return Namespace URI bound to prefix in the current scope 145 * 146 * @throws IllegalArgumentException When {@code prefix} is 147 * {@code null} 148 */ 149 String getNamespaceURI(String prefix); 150 151 /** 152 * Get prefix bound to Namespace URI in the current scope. 153 * 154 * <p>To get all prefixes bound to a Namespace URI in the current 155 * scope, use {@link #getPrefixes(String namespaceURI)}. 156 * 157 * <p>When requesting a prefix by Namespace URI, the following 158 * table describes the returned prefix value for all Namespace URI 159 * values: 160 * 161 * <table border="2" rules="all" cellpadding="4"> 162 * <thead> 163 * <tr> 164 * <th align="center" colspan="2"> 165 * {@code getPrefix(namespaceURI)} return value for 166 * specified Namespace URIs 167 * </th> 168 * </tr> 169 * <tr> 170 * <th>Namespace URI parameter</th> 171 * <th>prefix value returned</th> 172 * </tr> 173 * </thead> 174 * <tbody> 175 * <tr> 176 * <td>{@code <default Namespace URI>}</td> 177 * <td>{@code XMLConstants.DEFAULT_NS_PREFIX} ("") 178 * </td> 179 * </tr> 180 * <tr> 181 * <td>bound Namespace URI</td> 182 * <td>prefix bound to Namespace URI in the current scope, 183 * if multiple prefixes are bound to the Namespace URI in 184 * the current scope, a single arbitrary prefix, whose 185 * choice is implementation dependent, is returned</td> 186 * </tr> 187 * <tr> 188 * <td>unbound Namespace URI</td> 189 * <td>{@code null}</td> 213 * {@code null} 214 */ 215 String getPrefix(String namespaceURI); 216 217 /** 218 * Get all prefixes bound to a Namespace URI in the current 219 * scope. 220 * 221 * <p>An Iterator over String elements is returned in an arbitrary, 222 * <strong>implementation dependent</strong>, order. 223 * 224 * <p><strong>The {@code Iterator} is 225 * <em>not</em> modifiable. e.g. the 226 * {@code remove()} method will throw 227 * {@code UnsupportedOperationException}.</strong> 228 * 229 * <p>When requesting prefixes by Namespace URI, the following 230 * table describes the returned prefixes value for all Namespace 231 * URI values: 232 * 233 * <table border="2" rules="all" cellpadding="4"> 234 * <thead> 235 * <tr> 236 * <th align="center" colspan="2">{@code 237 * getPrefixes(namespaceURI)} return value for 238 * specified Namespace URIs</th> 239 * </tr> 240 * <tr> 241 * <th>Namespace URI parameter</th> 242 * <th>prefixes value returned</th> 243 * </tr> 244 * </thead> 245 * <tbody> 246 * <tr> 247 * <td>bound Namespace URI, 248 * including the {@code <default Namespace URI>}</td> 249 * <td> 250 * {@code Iterator} over prefixes bound to Namespace URI in 251 * the current scope in an arbitrary, 252 * <strong>implementation dependent</strong>, 253 * order 254 * </td> 255 * </tr> 256 * <tr> 257 * <td>unbound Namespace URI</td> 258 * <td>empty {@code Iterator}</td> 259 * </tr> | 71 * @see javax.xml.XMLConstants 72 * javax.xml.XMLConstants for declarations of common XML values 73 * @see <a href="http://www.w3.org/TR/xmlschema-2/#QName"> 74 * XML Schema Part2: Datatypes</a> 75 * @see <a href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames"> 76 * Namespaces in XML</a> 77 * @see <a href="http://www.w3.org/XML/xml-names-19990114-errata"> 78 * Namespaces in XML Errata</a> 79 * @since 1.5 80 */ 81 82 public interface NamespaceContext { 83 84 /** 85 * Get Namespace URI bound to a prefix in the current scope. 86 * 87 * <p>When requesting a Namespace URI by prefix, the following 88 * table describes the returned Namespace URI value for all 89 * possible prefix values: 90 * 91 * <table class="striped"> 92 * <caption>Return value for specified prefixes</caption> 93 * <thead> 94 * <tr> 95 * <th>prefix parameter</th> 96 * <th>Namespace URI return value</th> 97 * </tr> 98 * </thead> 99 * <tbody> 100 * <tr> 101 * <td>{@code DEFAULT_NS_PREFIX} ("")</td> 102 * <td>default Namespace URI in the current scope or 103 * <code> {@link 104 * javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI("")} 105 * </code> 106 * when there is no default Namespace URI in the current scope</td> 107 * </tr> 108 * <tr> 109 * <td>bound prefix</td> 110 * <td>Namespace URI bound to prefix in current scope</td> 111 * </tr> 112 * <tr> 113 * <td>unbound prefix</td> 114 * <td> 115 * <code> {@link 116 * javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI("")} 136 * 137 * @param prefix prefix to look up 138 * 139 * @return Namespace URI bound to prefix in the current scope 140 * 141 * @throws IllegalArgumentException When {@code prefix} is 142 * {@code null} 143 */ 144 String getNamespaceURI(String prefix); 145 146 /** 147 * Get prefix bound to Namespace URI in the current scope. 148 * 149 * <p>To get all prefixes bound to a Namespace URI in the current 150 * scope, use {@link #getPrefixes(String namespaceURI)}. 151 * 152 * <p>When requesting a prefix by Namespace URI, the following 153 * table describes the returned prefix value for all Namespace URI 154 * values: 155 * 156 * <table class="striped"> 157 * <caption>Return value for specified Namespace URIs</caption> 158 * <thead> 159 * <tr> 160 * <th>Namespace URI parameter</th> 161 * <th>prefix value returned</th> 162 * </tr> 163 * </thead> 164 * <tbody> 165 * <tr> 166 * <td>{@code <default Namespace URI>}</td> 167 * <td>{@code XMLConstants.DEFAULT_NS_PREFIX} ("") 168 * </td> 169 * </tr> 170 * <tr> 171 * <td>bound Namespace URI</td> 172 * <td>prefix bound to Namespace URI in the current scope, 173 * if multiple prefixes are bound to the Namespace URI in 174 * the current scope, a single arbitrary prefix, whose 175 * choice is implementation dependent, is returned</td> 176 * </tr> 177 * <tr> 178 * <td>unbound Namespace URI</td> 179 * <td>{@code null}</td> 203 * {@code null} 204 */ 205 String getPrefix(String namespaceURI); 206 207 /** 208 * Get all prefixes bound to a Namespace URI in the current 209 * scope. 210 * 211 * <p>An Iterator over String elements is returned in an arbitrary, 212 * <strong>implementation dependent</strong>, order. 213 * 214 * <p><strong>The {@code Iterator} is 215 * <em>not</em> modifiable. e.g. the 216 * {@code remove()} method will throw 217 * {@code UnsupportedOperationException}.</strong> 218 * 219 * <p>When requesting prefixes by Namespace URI, the following 220 * table describes the returned prefixes value for all Namespace 221 * URI values: 222 * 223 * <table class="striped"> 224 * <caption>Return value for specified Namespace URIs</caption> 225 * <thead> 226 * <tr> 227 * <th>Namespace URI parameter</th> 228 * <th>prefixes value returned</th> 229 * </tr> 230 * </thead> 231 * <tbody> 232 * <tr> 233 * <td>bound Namespace URI, 234 * including the {@code <default Namespace URI>}</td> 235 * <td> 236 * {@code Iterator} over prefixes bound to Namespace URI in 237 * the current scope in an arbitrary, 238 * <strong>implementation dependent</strong>, 239 * order 240 * </td> 241 * </tr> 242 * <tr> 243 * <td>unbound Namespace URI</td> 244 * <td>empty {@code Iterator}</td> 245 * </tr> |