2

XSLのソリューションを使用する: ウィドウを防ぐ簡単な方法はありますか? DOM で奇妙なタグを作成します。

名前の要素を挿入しないようにする方法はありますか? 現在、実行すると

<xsl:apply-templates select="solution-headline" mode="widow-fix" /> 

それは挿入します

<solution-headline>Lorem ipsum<solution-headline/> 

挿入してほしい

<xsl:text>Lorem ipsum<xsl:text/>
4

1 に答える 1

2

If you just want the text then the simplest approach would be to apply the widow-fix templates to just the text node children of the solution-headline element rather than to the element itself:

<xsl:apply-templates select="solution-headline/text()" mode="widow-fix" />

If you always want the widow-fixing to give you just the text and not include the surrounding element, then delete the existing template

<xsl:template match="* | @*" mode="widow-fix">
    <xsl:copy>
        <xsl:apply-templates select="@* | node()" mode="widow-fix"/>
    </xsl:copy>
</xsl:template>

widow-fix テンプレートを適用すると、デフォルトのテンプレートsolution-headlineが使用されます。このテンプレートは基本的にを使用せに(つまり、同じモードを使用してすべての子ノードを処理します) 、widow-fixing によって処理されたすべての子孫テキスト ノードを取得します。テンプレート。<xsl:apply-templates mode="widow-fix" />copy

于 2013-11-23T15:25:36.237 に答える