I have some XML like so:
<subsection number="5">
<p>
(5) The <link path="123">Secretary of State</link> shall appoint such as....
</p>
</subsection>
I can't change the XML and I need to strip out the (5) at the start of the paragraph and use the number attribute in the parent tag to create a new paragraph number with appropriate markup:
<xsl:template match="subsection/p">
<xsl:variable name="number">
<xsl:text>(</xsl:text>
<xsl:value-of select="../@number"/>
<xsl:text>)</xsl:text>
</xsl:variable>
<xsl:variable name="copy">
<xsl:value-of select="."/>
</xsl:variable>
<p>
<span class="indent">
<xsl:value-of select="$number" />
</span>
<span class="copy">
<xsl:value-of select="substring-after($copy, $number)" />
</span>
</p>
</xsl:template>
The problem is the rest of the paragraph may contain more XML that needs to be transformed, such as the link tag in the example.
I don't know how to apply templates to this once I've used the substring-after function.