XSLT 关于子节点和其他文本的放置

XSLT on the placement of a child node and other text

我要区分一个子节点的三个位置:

<a><b>BBB</b> some other text</a>
<a>some other text <b>BBB</b></a>
<a>some other <b>BBB</b> text </a>

我怎么知道是在文本的开头,还是在结尾,中间没有任何文本?

(xslt 2.0)

例如你可以写三个匹配模式

<xsl:template match="a/b[not(preceding-sibling::node())]">...</xsl:template>

<xsl:template match="a/b[preceding-sibling::node() and following-sibling::node()]">...</xsl:template>

<xsl:template match="a/b[not(following-sibling::node())]">...</xsl:template>

区分b个子元素的树型。