I have been beating my head against the wall with an XSLT issue for a couple of hours, and I clearly am lost.
I am trying to transform some XML to HTML. The relevant portion of my source XML looks like this:
Code:
<div xml:id="sect107" type="section" n="107">
<head>F. Indefinite Pronouns.</head>
<p/>
<div xml:id="sect107.1" type="subsection" n="1">
<p/>
[...]
</div>
</div>
And I have an XSL version 2.0 stylesheet that contains this template:
Code:
<!-- match first <p> within <div> -->
<xsl:template match="tei:div/tei:p[not(preceding-sibling::tei:p)]">
<xsl:for-each select=".">
<xsl:variable name="sectTop" select="ancestor::tei:div[@type='section'][1]/descendant::tei:p[1]=current()"/>
[...]
</xsl:for-each>
</xsl:template>
When this template matches the second <p> tag in my XML, I am expecting the variable $sectTop to be false, but it is in fact True. This is contrary to my (limited) understanding of how XPath expressions work. Since the <p> tag in question is the second descendant of its div ancestor, and not the first, the boolean expression should evaluate as False.
Can someone kindly enlighten me as to why I am getting this unexpected result?
I am sure this problem is a result of my ignorance, but for what it is worth, I am using Saxon-PE 9.2.0.2 as my transformer.
Many thanks in advance.