すべての索引用語をセクションごとに検索したいのですが、セクションがネストされています。簡単な例を次に示します。
<chapter>
<section><title>First Top Section</title>
<indexterm text="dog"/>
<para>
<indexterm text="tree"/>
</para>
<section><title>SubSection</title>
<indexterm text="cat"/>
</section>
</section>
<section><title>Second Top Section</title>
<indexterm text="elephant" />
</section>
</chapter>
次のような結果を得る xpath 式はありますか?
First Top Section = ["dog", "tree"]
Subsection = ["cat"]
Second Top Section = ["elephant"]
もちろん、次のような式を使用して、セクションの下にあるすべての子孫索引用語を取得します。
/chapter/section//indexterm
しかし、indexterm は、セクション内の他の要素内にある場合があります。それらは必ずしも子要素ではありません。
xpath を使用して、親セクションに固有の索引用語を取得することは可能ですか?