<xsl:apply-templates>
に関する質問があります。XSLT:<apply-templates select = "...">
<transcription>
<subst>
<del>wrong</del>
<add>right</add>
</subst>
</transcription>
は今、私はXSLTを使用してさまざまな方法で転写のこの記録を処理したい:
は、私は(http://www.tei-c.org/release/doc/tei-p5-doc/en/html/ref-subst.htmlを参照)、このようなXMLを持っていると仮定します。
私は、ユーザーに訂正を提示したい場合は、私はこのようなXSLTテンプレートを使用することができます。
<xsl:template match="subst"><xsl:apply-templates select="./add"/></xsl:template>
<xsl:template match="subst/add"><xsl:apply-templates/></xsl:template>
しかし、私も書くことができます:最初のケースで
<xsl:template match="subst"><xsl:apply-templates/></xsl:template>
<xsl:template match="subst/add"><xsl:apply-templates/></xsl:template>
<!-- del: ignore contents -->
<xsl:template match="subst/del"></xsl:template>
を私はadd
を<subst>
の中に明示的にしか指定せず、<del>
を無視します。
2番目のケースでは、要素と何もしないテンプレートを指定することで、同じ効果が得られるので、私は<del>
を無視します。
私が間違っていない場合、2つの方法は同等です。どれが望ましいですか?
あなたの入力に 'subst'はありませんので、' 'は何もしません。 –
あなたはテンプレートを持っていないので、あなたは "delを無視していません"。それはデフォルトのテンプレートに当てられます。 –
申し訳ありませんが、subst要素を追加するのを忘れていました。 Thx、Stefan、あなたのコメントは役に立ちました! – user130685