[ 
https://issues.apache.org/jira/browse/TAP5-2827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18091998#comment-18091998
 ] 

ASF subversion and git services commented on TAP5-2827:
-------------------------------------------------------

Commit ac303ede811a23edbab86039b32946c63b386748 in tapestry-5's branch 
refs/heads/javax from Ben Weidig
[ https://gitbox.apache.org/repos/asf?p=tapestry-5.git;h=ac303ede8 ]

TAP5-2827: tapestry-core DOM XPath support (#59)

Introduces a Jaxen-based XPath engine for querying Tapestry's DOM tree.

New API:
- `XPath` (org.apache.tapestry5.dom.xpath): factory-style entry point for
  compiling and executing XPath expressions against a Document or Node context
- `BoundXPath` (org.apache.tapestry5.dom): fluent wrapper returned by
  Node#xpath(String) that binds an expression to a context node, avoiding
  repetition of the context in chained calls
- `DocumentNavigator`: Jaxen Navigator implementation that adapts
  Tapestry's DOM node types (Element, Text, CData, Comment, Raw) to the
  Jaxen model
- `NodeVisitor`: new visitor interface used internally by DocumentNavigator
- `XPathException`: unchecked exception wrapping Jaxen errors

Existing DOM classes were extended to support the navigator and expose the new
xpath(String) entry point.


> DOM types should support XPath, better navigation/mutation
> ----------------------------------------------------------
>
>                 Key: TAP5-2827
>                 URL: https://issues.apache.org/jira/browse/TAP5-2827
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.10.0
>            Reporter: Ben Weidig
>            Assignee: Ben Weidig
>            Priority: Minor
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
>  
> h2. Description
> The types in {{org.apache.tapestry5.dom}} only allow rudimentary 
> lookups/navigation/mutability.
> To improve versatility, we should include "the usual suspects" of tree-based 
> XML data structures:
>  * XPath (inspired by 
> [https://tapestryxpath.sourceforge.net|https://tapestryxpath.sourceforge.net/]))
>  * Sibling navigation
>  * Mutability (clone, detach, replace)
>  * Improved Visitor
> h2. XPath
> Even though the JDK includes w3c XPath support, it is more of a timecapsule 
> with certain quirks.
> That's why Jaxen 2.0.0 would be used.
> [https://tapestryxpath.sourceforge.net|https://tapestryxpath.sourceforge.net/]
>  was based on Jaxen 1.0.0 but the principle is the same, we need 
> DocumentNavigator.
> There will be an {{XPath}} type that share instances, which accepts 
> {{{}Node{}}}.
> But to make it more versatile, there will also be an {{xpath(String)}} method 
> on the {{Node}} type itself, creating a {{BoundXPath}} with the node as its 
> origin, creating a nicer fluent API:
>  
> {code:java}
> XPath.of("ul/li").selectElements(element)
> vs
> element.xpath("ul/li").elements()
> {code}
>  
> h2. Sibling Navigation
> Adding {{getNextSibling()}} and {{getPreviousSibling())}} to {{Node}} and its 
> implementations
> h2. Mutability
> We can already remove nodes, but not detach them, so {{detach()}} gets added.
> With detached nodes, we also need insert/append/replace-related methods.
> h2. Improved Visitor
> Currently, the {{org.apache.tapestry5.dom.Visitor}} only supports {{Element}} 
> nodes.
> If possible in a non-breaking way, it should be expanded to visit all 
> {{Node}} types.
> If not, a new {{NodeVisitor}} could be added.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to