|
1 | 1 | /* |
2 | | - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
87 | 87 | * </blockquote> |
88 | 88 | * |
89 | 89 | * <p> |
90 | | - * This example would select the <code><bar></code> element in |
| 90 | + * This example would select the {@code <bar>} element in |
91 | 91 | * an XML document such as the following: |
92 | 92 | * |
93 | 93 | * <blockquote> |
|
98 | 98 | * </pre> |
99 | 99 | * </blockquote> |
100 | 100 | * |
101 | | - * <p>The expression <code>/foo/bar</code> is an example of a location |
| 101 | + * <p>The expression {@code /foo/bar} is an example of a location |
102 | 102 | * path. While XPath location paths resemble Unix-style file system |
103 | 103 | * paths, an important distinction is that XPath expressions return |
104 | 104 | * <em>all</em> nodes that match the expression. Thus, all three |
105 | | - * <code><bar></code> elements in the following document would be |
106 | | - * selected by the <code>/foo/bar</code> expression: |
| 105 | + * {@code <bar>} elements in the following document would be |
| 106 | + * selected by the {@code /foo/bar} expression: |
107 | 107 | * |
108 | 108 | * <blockquote> |
109 | 109 | * <pre> |
|
116 | 116 | * </blockquote> |
117 | 117 | * |
118 | 118 | * <p> |
119 | | - * A special location path operator, <code>//</code>, selects nodes at |
| 119 | + * A special location path operator, {@code //}, selects nodes at |
120 | 120 | * any depth in an XML document. The following example selects all |
121 | | - * <code><bar></code> elements regardless of their location in a |
| 121 | + * {@code <bar>} elements regardless of their location in a |
122 | 122 | * document: |
123 | 123 | * |
124 | 124 | * <blockquote> |
|
130 | 130 | * <p> |
131 | 131 | * A wildcard operator, *, causes all element nodes to be selected. |
132 | 132 | * The following example selects all children elements of a |
133 | | - * <code><foo></code> element: |
| 133 | + * {@code <foo>} element: |
134 | 134 | * |
135 | 135 | * <blockquote> |
136 | 136 | * <pre> |
|
158 | 158 | * <code>/foo/bar/<strong>@id</strong></code> |
159 | 159 | * </th> |
160 | 160 | * <td> |
161 | | - * Selects the attribute <code>id</code> of the <code><bar></code> element |
| 161 | + * Selects the attribute {@code id} of the {@code <bar>} element |
162 | 162 | * </td> |
163 | 163 | * </tr> |
164 | 164 | * <tr> |
165 | 165 | * <th scope="row"><code>/foo/bar/<strong>text()</strong></code> |
166 | 166 | * </th> |
167 | 167 | * <td> |
168 | | - * Selects the text nodes of the <code><bar></code> element. No |
| 168 | + * Selects the text nodes of the {@code <bar>} element. No |
169 | 169 | * distinction is made between escaped and non-escaped character data. |
170 | 170 | * </td> |
171 | 171 | * </tr> |
172 | 172 | * <tr> |
173 | 173 | * <th scope="row"><code>/foo/bar/<strong>comment()</strong></code> |
174 | 174 | * </th> |
175 | 175 | * <td> |
176 | | - * Selects all comment nodes contained in the <code><bar></code> element. |
| 176 | + * Selects all comment nodes contained in the {@code <bar>} element. |
177 | 177 | * </td> |
178 | 178 | * </tr> |
179 | 179 | * <tr> |
180 | 180 | * <th scope="row"><code>/foo/bar/<strong>processing-instruction()</strong></code> |
181 | 181 | * </th> |
182 | 182 | * <td> |
183 | 183 | * Selects all processing-instruction nodes contained in the |
184 | | - * <code><bar></code> element. |
| 184 | + * {@code <bar>} element. |
185 | 185 | * </td> |
186 | 186 | * </tr> |
187 | 187 | * </tbody> |
|
191 | 191 | * Predicates allow for refining the nodes selected by an XPath |
192 | 192 | * location path. Predicates are of the form |
193 | 193 | * <code>[<em>expression</em>]</code>. The following example selects all |
194 | | - * <code><foo></code> elements that contain an <code>include</code> |
195 | | - * attribute with the value of <code>true</code>: |
| 194 | + * {@code <foo>} elements that contain an {@code include} |
| 195 | + * attribute with the value of {@code true}: |
196 | 196 | * |
197 | 197 | * <blockquote> |
198 | 198 | * <pre> |
|
219 | 219 | * following data types: |
220 | 220 | * |
221 | 221 | * <ul> |
222 | | - * <li><code>Boolean</code></li> |
223 | | - * <li><code>Number</code></li> |
224 | | - * <li><code>String</code></li> |
| 222 | + * <li>{@code Boolean}</li> |
| 223 | + * <li>{@code Number}</li> |
| 224 | + * <li>{@code String}</li> |
225 | 225 | * </ul> |
226 | 226 | * |
227 | 227 | * <a id="XPath.Datatypes.QName"></a> |
|
239 | 239 | * <p> |
240 | 240 | * The return type is specified by a {@link javax.xml.namespace.QName} parameter |
241 | 241 | * in method call used to evaluate the expression, which is either a call to |
242 | | - * <code>XPathExpression.evalute(...)</code> or <code>XPath.evaluate(...)</code> |
| 242 | + * {@code XPathExpression.evalute(...)} or {@code XPath.evaluate(...)} |
243 | 243 | * methods. |
244 | 244 | * |
245 | 245 | * <p> |
246 | | - * When a <code>Boolean</code> return type is requested, |
247 | | - * <code>Boolean.TRUE</code> is returned if one or more nodes were |
248 | | - * selected; otherwise, <code>Boolean.FALSE</code> is returned. |
| 246 | + * When a {@code Boolean} return type is requested, |
| 247 | + * {@code Boolean.TRUE} is returned if one or more nodes were |
| 248 | + * selected; otherwise, {@code Boolean.FALSE} is returned. |
249 | 249 | * |
250 | 250 | * <p> |
251 | | - * The <code>String</code> return type is a convenience for retrieving |
| 251 | + * The {@code String} return type is a convenience for retrieving |
252 | 252 | * the character data from a text node, attribute node, comment node, or |
253 | 253 | * processing-instruction node. When used on an element node, the value |
254 | 254 | * of the child text nodes is returned. |
255 | 255 | * |
256 | 256 | * <p> |
257 | | - * The <code>Number</code> return type attempts to coalesce the text |
258 | | - * of a node to a <code>double</code> data type. |
| 257 | + * The {@code Number} return type attempts to coalesce the text |
| 258 | + * of a node to a {@code double} data type. |
259 | 259 | * |
260 | 260 | * <a id="XPath.Datatypes.Class"></a> |
261 | 261 | * <h2>3.2 Class types</h2> |
262 | 262 | * In addition to the QName types, the XPath API supports the use of Class types |
263 | | - * through the <code>XPathExpression.evaluteExpression(...)</code> or |
264 | | - * <code>XPath.evaluateExpression(...)</code> methods. |
| 263 | + * through the {@code XPathExpression.evaluateExpression(...)} or |
| 264 | + * {@code XPath.evaluateExpression(...)} methods. |
265 | 265 | * |
266 | 266 | * The XPath data types are mapped to Class types as follows: |
267 | 267 | * <ul> |
268 | | - * <li><code>Boolean</code> -- <code>Boolean.class</code></li> |
269 | | - * <li><code>Number</code> -- <code>Number.class</code></li> |
270 | | - * <li><code>String</code> -- <code>String.class</code></li> |
271 | | - * <li><code>Nodeset</code> -- <code>XPathNodes.class</code></li> |
272 | | - * <li><code>Node</code> -- <code>Node.class</code></li> |
| 268 | + * <li>{@code Boolean} -- {@code Boolean.class}</li> |
| 269 | + * <li>{@code Number} -- {@code Number.class}</li> |
| 270 | + * <li>{@code String} -- {@code String.class}</li> |
| 271 | + * <li>{@code Nodeset} -- {@code XPathNodes.class}</li> |
| 272 | + * <li>{@code Node} -- {@code Node.class}</li> |
273 | 273 | * </ul> |
274 | 274 | * |
275 | 275 | * <p> |
276 | | - * Of the subtypes of Number, only Double, Integer and Long are supported. |
| 276 | + * Of the subtypes of {@code Number}, only {@code Double, Integer} and {@code Long} are supported. |
277 | 277 | * |
278 | 278 | * <a id="XPath.Datatypes.Enum"></a> |
279 | 279 | * <h2>3.3 Enum types</h2> |
280 | 280 | * Enum types are defined in {@link javax.xml.xpath.XPathEvaluationResult.XPathResultType} |
281 | 281 | * that provide mappings between the QName and Class types above. The result of |
282 | | - * evaluating an expression using the <code>XPathExpression.evaluteExpression(...)</code> |
283 | | - * or <code>XPath.evaluateExpression(...)</code> methods will be of one of these types. |
| 282 | + * evaluating an expression using the {@code XPathExpression.evaluateExpression(...)} |
| 283 | + * or {@code XPath.evaluateExpression(...)} methods will be of one of these types. |
| 284 | + * <p> |
| 285 | + * Note the differences between the Enum and <a href="#XPath.Datatypes.QName">QName</a> |
| 286 | + * mappings: |
| 287 | + * <ul> |
| 288 | + * <li>{@link javax.xml.xpath.XPathConstants#NUMBER NUMBER}<br> |
| 289 | + * The Enum mapping for {@link javax.xml.xpath.XPathConstants#NUMBER NUMBER} |
| 290 | + * supports {@code Double, Integer} and {@code Long}.<br><br> |
| 291 | + * </li> |
| 292 | + * <li>{@link javax.xml.xpath.XPathConstants#NODESET NODESET}<br> |
| 293 | + * The Enum mapping for {@link javax.xml.xpath.XPathConstants#NODESET NODESET} |
| 294 | + * is {@link javax.xml.xpath.XPathNodes XPathNodes} instead of |
| 295 | + * {@link org.w3c.dom.NodeList NodeList} in the |
| 296 | + * <a href="#XPath.Datatypes.QName">QName</a> mapping. |
| 297 | + * </li> |
| 298 | + * </ul> |
284 | 299 | * |
285 | 300 | * <a id="XPath.Context"></a> |
286 | 301 | * <h2>4. XPath Context</h2> |
287 | 302 | * |
288 | 303 | * <p> |
289 | 304 | * XPath location paths may be relative to a particular node in the |
290 | | - * document, known as the <code>context</code>. A context consists of: |
| 305 | + * document, known as the {@code context}. A context consists of: |
291 | 306 | * <ul> |
292 | 307 | * <li>a node (the context node)</li> |
293 | 308 | * <li>a pair of non-zero positive integers (the context position and the context size)</li> |
|
316 | 331 | * </blockquote> |
317 | 332 | * |
318 | 333 | * <p> |
319 | | - * The <code><widget></code> element can be selected with the following process: |
| 334 | + * The {@code <widget>} element can be selected with the following process: |
320 | 335 | * |
321 | 336 | * <blockquote> |
322 | 337 | * <pre> |
|
335 | 350 | * </blockquote> |
336 | 351 | * |
337 | 352 | * <p> |
338 | | - * With a reference to the <code><widget></code> element, a |
| 353 | + * With a reference to the {@code <widget>} element, a |
339 | 354 | * relative XPath expression can be written to select the |
340 | | - * <code><manufacturer></code> child element: |
| 355 | + * {@code <manufacturer>} child element: |
341 | 356 | * |
342 | 357 | * <blockquote> |
343 | 358 | * <pre> |
|
363 | 378 | * NodeList nodes = (NodeList) xpath.evaluate(expression, inputSource, XPathConstants.NODESET); |
364 | 379 | * |
365 | 380 | * //or using the evaluateExpression method |
366 | | - * XPathNodes nodes = xpath.evaluate(expression, inputSource, XPathNodes.class); |
| 381 | + * XPathNodes nodes = xpath.evaluateExpression(expression, inputSource, XPathNodes.class); |
367 | 382 | * </pre> |
368 | 383 | * </blockquote> |
369 | 384 | * |
|
390 | 405 | * {@code evaluateExpression} method such as the following code: |
391 | 406 | * <blockquote> |
392 | 407 | * <pre> |
393 | | - * int count = xpath.evaluate("count(/widgets/widget)", document, Integer.class); |
| 408 | + * int count = xpath.evaluateExpression("count(/widgets/widget)", document, Integer.class); |
394 | 409 | * </pre> |
395 | 410 | * </blockquote> |
396 | 411 | * |
|
0 commit comments