()
| 314 | } |
| 315 | |
| 316 | private Evaluator byTag() { |
| 317 | // todo - these aren't dealing perfectly with case sensitivity. For case sensitive parsers, we should also make |
| 318 | // the tag in the selector case-sensitive (and also attribute names). But for now, normalize (lower-case) for |
| 319 | // consistency - both the selector and the element tag |
| 320 | String tagName = normalize(tq.consumeElementSelector()); |
| 321 | Validate.notEmpty(tagName); |
| 322 | |
| 323 | // namespaces: |
| 324 | if (tagName.startsWith("*|")) { // namespaces: wildcard match equals(tagName) or ending in ":"+tagName |
| 325 | String plainTag = tagName.substring(2); // strip *| |
| 326 | return new CombiningEvaluator.Or( |
| 327 | new Evaluator.Tag(plainTag), |
| 328 | new Evaluator.TagEndsWith(":" + plainTag) |
| 329 | ); |
| 330 | } else if (tagName.endsWith("|*")) { // ns|* |
| 331 | String ns = tagName.substring(0, tagName.length() - 2) + ":"; // strip |*, to ns: |
| 332 | return new Evaluator.TagStartsWith(ns); |
| 333 | } else if (tagName.contains("|")) { // flip "abc|def" to "abc:def" |
| 334 | tagName = tagName.replace("|", ":"); |
| 335 | } |
| 336 | |
| 337 | return new Evaluator.Tag(tagName); |
| 338 | } |
| 339 | |
| 340 | private Evaluator byAttribute() { |
| 341 | try (TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']'))) { |
no test coverage detected