私の入力は次のとおりです。
<w:body>
<w:p>
<w:pPr>
<w:pStyle w:val="paragraph"/>
</w:pPr>
<w:r><w:t>1274394 The milk costs , $1.99 [12] test Figure 1, Table 1</w:t></w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="paragraph"/>
</w:pPr>
<w:r><w:t>sample text Figure 1 and [1]</w:t></w:r>
</w:p>
</w:body>
XSLT「analyze-string」を使用して以下のような出力を取得したい
<w:body>
<w:p>
<w:pPr>
<w:pStyle w:val="paragraph"/>
</w:pPr>
<w:r><w:t>1274394 The milk costs , $1.99 <ref>[12]</ref> test <fig>Figure 1</fig>, <tab>Table 1</tab></w:t></w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="paragraph"/>
</w:pPr>
<w:r><w:t>sample text Figure 1 and [1]</w:t></w:r>
</w:p>
</w:body>
XSLTは以下のとおりです。
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="w:t/text()">
<xsl:variable name="phase1">
<xsl:apply-templates select="." mode="fig" />
</xsl:variable>
<xsl:variable name="phase2">
<xsl:apply-templates select="." mode="tab" />
</xsl:variable>
<xsl:apply-templates select="$phase1" mode="ref" />
</xsl:template>
<xsl:template match="text()" mode="fig">
<xsl:analyze-string select="." regex="Figure (\d{{1,2}})">
<xsl:matching-substring>
<fig>
<xsl:value-of select="." />
</fig>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="." />
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
<xsl:template match="text()" mode="ref">
<xsl:analyze-string select="." regex="\[(\d{{1,2}})\]">
<xsl:matching-substring>
<ref>
<xsl:value-of select="." />
</ref>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="." />
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
<xsl:template match="text()" mode="tab">
<xsl:analyze-string select="." regex="Table (\d{{1,2}})">
<xsl:matching-substring>
<tab>
<xsl:value-of select="." />
</tab>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="." />
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
<xsl:template match="@*|*|comment()|processing-instruction()" mode="ref">
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="ref"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
上記のXSLTを使用して、Figとrefを置き換えることができます。テーブルを置き換えるために、Phase2変数を使用していますが、出力が得られません。これを行う別の方法はありますか?