What is the fastest way to find whether the current node is in path of a node with a specific attribute, given this xml structure:
<root>
<item>
<item name="x">
<item></item>
<item name="y"></item>
<item></item>
</item>
<item></item>
<item></item>
</item>
<item>
<item name="z"></item>
<item></item>
</item>
I have a xslt variable to tell me what the current active node is.
I want to execute some code if the current node is in path of the node with the @name x.
So that if the active node is the item with @name y the code should execute, if the current active node is item with @name z it shouldn't.
My best solution so far is:
ancestor-or-self::item[@name = 'x']
But as there are 30k+ item nodes this is taking forever to render, is there a faster way? (XSLT/XPATH 2 is not an option)
ancestor-or-self
shouldn't be so heavy in performance. The problem must be in your transformation pattern: running this for every node should have a cost in performance. – user357812@match
, rather than buried within a template, because XSLT engines can apply optimizations more easily on the@match
. – Mads Hansen