I am trying to run this XPath expression (that is, trying to count how many element content strings in my XML file end with letter-one-f ('a') or letter-two-f ('A'):
<xsl:value-of select="count( substring(.,string-length(.) -1,string-length(.) -1)=$letter-one-f or substring(., string-length(.) -1,string-length(.) -1)=$letter-two-f )"/>
but I don't know how to refer to the 'current value'. All I know is that it's usually represented by a dot '.' . I don't know where to put 'template match' or if that is even needed.
This code, on the other hand, works, because I have specified that it should look in '/n-grams-sorted/n-gram':
<xsl:value-of select="count(/n-grams-sorted/n-gram[starts-with(.,$letter-one-f) or starts-with(.,$letter-two-f) ])"/>
I just don't know how to apply this to the first expression. Where am I going to get 'the current value'? How am I going to tell it that I want to look in '/n-grams-sorted/n-gram'? It's all I need to get my expression working (I tried it in my editor's 'xpath view').
Source XML file sample:
<n-grams-sorted analysis="N_GRAM_TOKEN3" range="Total Set">
<n-gram position="1" frequency="3535" probability="0.0447735">. = =</n-gram>
<n-gram position="2" frequency="322" probability="0.0040784">= = De</n-gram>
<n-gram position="3" frequency="284" probability="0.0035971">= = Het</n-gram>
<n-gram position="4" frequency="207" probability="0.0026218">= = Hij</n-gram>
<n-gram position="5" frequency="168" probability="0.0021278">= = Dit</n-gram>
I have already tried everything I could think of and this issue has been bothering me for a week. This is what I last tried:
<xsl:value-of select="count( ./n-gram[substring(current(),1,string-length(current()) -1)=$letter-one-f or substring(current(),1,string-length(current())=$letter-two-f ) ] )"/>
My full code:
http://pastebin.com/TaKB6Bbd
Any ideas?
Thank you,
--
uid1