ID テンプレートと、ソース内の潜在的な XPath に一致するいくつかのテンプレートを使用して、XSLT を作成しました。ただし、一致するパスが常に存在するとは限りません。一致するテンプレートが適用される前にパスを「挿入」する方法はありますか? XSLT は手続き的に実行されないことを知っているので、これを行う方法がわかりませんでした。以下に例を示します。
これが XSLT だとしましょう:
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
<xsl:template match='pathA'>
do stuff
</xsl:template>
<xsl:template match='pathB'>
do something
</xsl:template>
<xsl:template match='pathC'>
do other stuff
</xsl:template>
そして、入力でこれを言いましょう:
<root>
<Child>
<pathA>I have Data!</pathA>
<pathC>We skipped B!</pathC>
</Child>
</root>
pathB
XPath に一致するテンプレートを実行できるように「作成」する方法はありますか?
ご協力いただきありがとうございます。