[xsl] count nodes which are previous to a given node and have to meet xpath condition

Subject: [xsl] count nodes which are previous to a given node and have to meet xpath condition
From: "Markus Ohlenroth markus.ohlenroth@xxxxxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 14 Jul 2015 08:54:09 -0000
Using xsl 1.0
the below example contains several nodes named <instrText>. 
Having obtained the node <instrText> whose text contains value 6
I want to count all previous instrText nodes whose text starts with
"HYPERLINK"
and are buried at any level within the same  record/Kommentar/body/section
tree as the node with value 6 


So in my example the count result should be "4"
I stumble when I try to count nodes which are previous to a given node but
have to meet the above xpath condition
Thanks in advance for any advice.
Regards Markus



<?xml version="1.0" encoding="UTF-8"?>
<file>
<record>
<Kommentar>
<body>
<sect>
	<p>
		<r>
			<instrText>HYPERLINK \l "anchor" \t "1"</instrText>
		</r>
	</p>
	<p>
		<r>
			<instrText>HYPERLINK \l "anchor" \t "2"</instrText>
		</r>
	</p>
</sect>
</body>
</Kommentar>
</record>


<record>
   <Kommentar>
<body>
<sect>
	<p>
		<r>
			<instrText>HYPERLINK \l "anchor" \t "3"</instrText>
			<instrText>HYPERLINK \l "anchor" \t "4</instrText>
		</r>
	</p>
	<p>
		<r>
			<rPr>
				<rFonts ascii="BLG New Garamond" h-ansi="BLG
New Garamond"/>
				<sz val="32"/>
			</rPr>
			<instrText>HYPERLINK \l "anchor" \t "5"</instrText>
		</r>
	</p>
	<p>
		<r>
			<instrText>HYPERLINK \l "anchor" \t "6"</instrText>
		</r>
	</p>
</sect>
</body>
</Kommentar>
</record>
</file>

Current Thread