I have seen questions where following-sibling has been applied based on a node’s value but my issue is related to the actual node itself.
This is the type of XML I have have:
<Employee>
<Summary>
<A>
<B>
</Summary>
<Elections>
</Elections>
<Employee>
I need to write a Xpath condition as follows:
if (NOT(the following sibling(first sibling) of /Employee/Summary is Elections)), then do something.
Currently I have:
<xsl:if test="(not(following-sibling::Employee/Summary[1]='Earnings'))
<xsl:call-template name="EmployeeRecord"/>
</xsl:if>
Please note that I am not checking a node value but the node itself(i.e the node name).
Any help in the right direction will be much appreciated.
You are on the right track. The
following-siblingaxis evaluates from the context node in the previous step.if you are looking for the first element that is the following-sibling of
/Employee/Summary, you would use:/Employee/Summary/following-sibling::*[1].In order to evaluate whether that first following-sibling is an
Electionselement, you can use an additional predicate filter[self::Elections].not()Putting it all together, adjusting your example: