2

プレーンな HTML を生成する XSLT ファイルがあります。一部の要素を CDATA ブロックでラップする必要があるため、cdata-section-elements を使用する予定です。しかし、CDATA を含めたい要素が<p>ページ上に 1 つしかない場合、他のすべての<p>要素に CDATA を配置しないようにするにはどうすればよいでしょうか?

入力データは次のとおりです。

<item>
  ...
  <g:category>Gifts under &amp;pound;10</g:category>
</item>

私のXSLは:

<xsl:element name="a">
  <xsl:attribute name="href">productlist.aspx</xsl:attribute>
  <xsl:copy-of select="text()" />
</xsl:element>

これを次のようにレンダリングしたい:

Gifts under £10

しかし、私が得るのは次のとおりです。

Gifts under &pound;10
4

2 に答える 2

0

私が持っているコードは次のとおりです。

<xsl:element name="a">
  <xsl:attribute name="href">
    product.aspx?prod=<xsl:copy-of select="title/text()" />
  </xsl:attribute>
  <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
  <xsl:copy-of select="g:price" /> - <xsl:copy-of select="title/text()" />
  <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
</xsl:element>
于 2009-10-30T16:53:30.533 に答える