I would like to transform Processing instructions with open/close tags like so:
<para><?Pub _font Weight="bold"?>Date Re-inspected<?Pub /_font?></para>
to
<div class="x-para-9-5"><span style="font-weight: bold">Date Re-inspected</span></div>
I tried to implement Processing instructions transform but the second copy of the first PI's immediate-sibling text node is not being deleted (and as a novice, I don't understand why this code would delete it):
My undesired result:
<div class="x-para-9-5"><span style="font-weight:bold;">Date Re-inspected</span>Date Re-inspected</div>
This is my code, slightly modified from the other question referenced above:
<xsl:template match="processing-instruction('Pub')">
<xsl:choose>
<xsl:when test="starts-with(., '_font')">
<xsl:choose>
<xsl:when test="contains(.,'bold')">
<span style="font-weight:bold;">
<xsl:apply-templates select="following-sibling::node()[1][self::text()]"/>
</span>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="starts-with(., '/_font')
| text()[preceding-sibling::node()[1][self::processing-instruction('_font')]]">
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:template>
Any advice appreciated, this is my first week with XSL.