Reputation: 884
I have a working scenario but don't know why a particular XPath is working. I iterate over three articles from a database, they are TEI XML. For all of them, I need to put endnotes at the end of a particular article (third in this case).
<xsl:for-each select="//tei:text">
<xsl:apply-templates select="tei:body"/>
<xsl:apply-templates select="*//tei:note"/>
</xsl:for-each>
If I use just //tei:note
, notes from the third article are present in all articles. If I use *//tei:note
, it works as expected. Am I anchoring the notes to some context or so?
Upvotes: 0
Views: 35
Reputation: 89285
//tei:note
returns all note
elements within current XML document, ignoring the context element. Commonly, you put a dot (.
) at the beginning to make it relative to the context element.
Regarding your working XPath, basically *
gets direct child elements, of any name, from current context element. So yes, you can say that you're 'anchoring' subsequent XPath, //tei:note
, to direct child of current contex element by saying *//tei:note
.
Upvotes: 1