Ben Weidig created TAP5-2827:
--------------------------------

             Summary: 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


 
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