如何从我知道其 id 的特定节点开始选择文本节点的前面节点,而不是从根节点获取文本节点?
当我从文本节点的模板匹配中调用以下部分时,我从根中获取所有前面的文本节点。我想修改上面的代码,只选择出现在具有特定 id 的节点之后的文本节点,比如 123。即类似于 //*[@id='123']
<xsl:template match="text()[. is $text-to-split]">
<xsl:variable name="split-index" as="xsd:integer"
select="$index - sum(preceding::text()/string-length(.))"/>
<xsl:value-of select="substring(., 1, $split-index - 1)"/>
<xsl:copy-of select="$new"/>
<xsl:value-of select="substring(., $split-index)"/>
</xsl:template>
<xsl:variable name="text-to-split" as="text()?"
select="descendant::text()[sum((preceding::text(), .)/string-length(.)) ge $index][1]"/>
我如何在我使用 before::text 的地方包含条件,以便选择相对于我知道的特定节点的 id 的前面的文本节点?