martinanton
martinanton

Reputation: 217

XSLT on the placement of a child node and other text

I have to differentiate between three positions of a child node:

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

how do I know if is at the beginning of the text, or at the end without any text in between?

(xslt 2.0)

Upvotes: 0

Views: 24

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167696

You can for instance write three match patterns

<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>

to distinguish the tree type of b child elements.

Upvotes: 1

Related Questions