I updated my code to use exists(. intersect
$elements-to-keep/ancestor-or-self::*) and that definitely works and I like
having a singleton on one side, but even my largest input document would not be
large enough to show a significant performance benefit.
Cheers,
Eliot
--
Eliot Kimber
http://contrext.com
On 2/24/18, 2:37 PM, "Michael Kay mike(_at_)saxonica(_dot_)com"
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
Your requirement is
IF any descendant of current element is in $elements-to-keep, process the
current element
and I suggested
> select="exists(.//* intersect $elements-to-keep)"
But I suspect the following would be better:
> select="exists(. intersect $elements-to-keep/ancestor-or-self::*)"
(That is, "if the current element is an ancestor-or-self of any element in
$elements-to-keep)
Enumerating the ancestors of an element is likely to be faster than
enumerating its descendants. Saxon also has a faster implementation of
"intersect" for use when one operand is a singleton.
But if you want to return false when "." is in $elements-to-keep (but none
of its descendants is) then you may need to tweak this slightly
Michael Kay
Saxonica
> On 24 Feb 2018, at 20:17, Eliot Kimber ekimber(_at_)contrext(_dot_)com
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
>
> So my misunderstanding of "=" is that it is comparing values, not
nodes--I clearly never understood that properly.
>
> That then explains why an empty element would produce the results I was
seeing: "" is equal to any other empty node.
>
> Doh!
>
> I will try Mike's intersection expression.
>
> Cheers
>
> W.
>
> --
> Eliot Kimber
> http://contrext.com
>
> On 2/23/18, 6:39 PM, "Michael Kay mike(_at_)saxonica(_dot_)com"
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
>
>
>> On 24 Feb 2018, at 00:18, G. Ken Holman
g(_dot_)ken(_dot_)holman(_at_)gmail(_dot_)com
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
>>
>> Ignore that second expression ... I wrote it too hastily and I'm now
back at my desk to think about it.
>>
>> This would work I think:
>>
>> <xsl:value-of select="some $this in .//* satisfies
>> some $that in $elements-to-keep
>> satisfies $this is $that"/>
>>
>
> I think that's equivalent to saying that the intersection of the two
sets is non empty:
>
> select="exists(.//* intersect $elements-to-keep)"
>
> Michael Kay
> Saxonica
>
>
>
>
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--