This question is similar: Using XSLT to create XSL-FO with nested bold/italic tags
However, I want to know if there is a way to handle (refer to) the text that is outside the nested element. For instance, if I use this:
<xsl:apply-templates select="." mode="handle-emphasis" />
To "call" the following templates:
<xsl:template match="p/emphasis[@type='italic']" mode="handle-emphasis">
<xsl:element name="i">
<xsl:value-of select="text()" />
</xsl:element>
</xsl:template>
<xsl:template match="p/emphasis[not(@type='italic')]" mode="handle-emphasis">
<xsl:element name="b">
<xsl:value-of select="text()" />
</xsl:element>
</xsl:template>
<xsl:template match="p/br" mode="handle-emphasis">
<xsl:element name="br" />
</xsl:template>
Then I am able to successfully handle some custom tags that are much like HTML bold and italic. However, if I create a template that matches just "p", it doesn't seem that template is executed for the text that is 'outside' the 'bold' and 'italic' nodes.
I am probably missing something simple, but this is driving me nuts. Any ideas much appreciated.
It looks as though you were wishing you had a template whose match pattern were
p/text().