[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XQuery/XPath 3.1: Node List to Node Set ("distinct
Hi, $nodes/. would re-order them in document order if that matters. FunctX also has a distinct-nodes function but I doubt that it would be considered obvious, and I also doubt that it would be as efficient as what you came up with: http://www.xqueryfunctions.com/xq/functx_distinct-nodes.html Hope everyone is having a nice holiday. Priscilla From: Eliot Kimber eliot.kimber@xxxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, December 28, 2021 2:24 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: XQuery/XPath 3.1: Node List to Node Set ("distinct nodes") Hmph. That is certainly much more efficient p but is not necessarily obvious (at least not to me). Thanks! E. _____________________________________________ Eliot Kimber Sr Staff Content Engineer O: 512 554 9368 M: 512 554 9368 servicenow.com<https://www.servicenow.com> LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow> From: Martin Honnen martin.honnen@xxxxxx<mailto:martin.honnen@xxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list-service@xxxxxxxxxxxx rytech.com>> Date: Tuesday, December 28, 2021 at 1:15 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list@xxxxxxxxxxxxxxxxxxxxxx> <xsl-list@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list@xxxxxxxxxxxxxxxxxxxxxx>> Subject: Re: XQuery/XPath 3.1: Node List to Node Set ("distinct nodes") [External Email] On 28.12.2021 20:10, Eliot Kimber eliot.kimber@xxxxxxxxxxxxxx<mailto:eliot.kimber@xxxxxxxxxxxxxx> wrote: > I couldnbt find an answer in my google and markmail searching so I > thought Ibd ask here: > > Given an arbitrary list of nodes that may contain duplicates, what is > the most efficient way to reduce the node list to a set? > > The solution I came up with is a recursive function: > > (: > > Get the unique nodes from the supplied sequence > > @param nodes The sequence of nodes to evaluate > > @return A sequence of nodes such that each node in $nodes exists exactly > once. > > :) > > declare function dutils:distinctNodes($nodes as node()*) as node()* { > > dutils:_getDistinctNodes($nodes, ()) > > }; > > declare function dutils:_getDistinctNodes($nodes as node()*, $resultList > as node()*) as node()* { > > if (exists($nodes)) > > then > > let $node := head($nodes) > > return dutils:_getDistinctNodes(tail($nodes), ($resultList | $node)) > > else $resultList > > }; > > Which works but I feel like Ibm missing some obvious way to do this more > directly, but Ibm not seeing it. > > Am I missing a better solution? $nodes/. XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe<http://lists.mulberrytech.com/unsub/xsl-list/2716978> (by email<>)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|