私は私の入力XMLがあり、その属性値を使用して、2つの段落を削除したい、私は以下の事を試してみましたが、それは出力で発生だ、属性値を使用して要素を含むコンテンツを削除するにはどうすればよいですか?
:私が使用
<chapter outputclass="chapter-Body">
<body class="- chapter/body ">
<p class="- chapter/p ">why now?</p>
<p class="- chapter/p " outputclass="Image_Size">Banner</p>
<fig>
<image href="3.jpg" outputclass="Fig-Image_Ref"/>
</fig>
<p class="- chapter/p ">But for others, it may not be.</p>
<image ref="4.png" outputclass="Image_Ref"/>
<p class="- chapter/p " outputclass="Image_Size">Small</p>
<p class="- chapter/p ">As result</p>
</body>
</chapter>
XSL:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="chapter[@outputclass='chapter-Body']">
<body>
<text>
<text_top><p><xsl:value-of select="body/fig/preceding-sibling::p[1]"/></p>
</text_top>
<text_bottom><p><xsl:value-of select="body/fig/following-sibling::p[1]"/></p>
<p><xsl:value-of select="body/fig/following-sibling::p[2]"/></p>
</text_bottom>
</text>
<xsl:apply-templates/>
</body>
</xsl:template>
<xsl:template match="p[@outputclass='Image_Size']"/>
</xsl:stylesheet>
XML出力私が得たとして:
<body>
<text>
<text_top>
<p>Banner</p>
</text_top>
<text_bottom>
<p>But for others, it may not be.</p>
<p>Small</p>
</text_bottom>
</text>
</body>
しかし、私は次のようになると期待しています:
<body>
<text>
<text_top>
<p>why now?</p>
</text_top>
<text_bottom>
<p>But for others, it may not be.</p>
<p>As result</p>
</text_bottom>
</text>
</body>
私はその特定の2つのパラの適用テンプレートを使用しましたが、出力されています。同じXSLTを使用してこれを修正するにはどうすればよいですか?
私はを外し、角括弧で数値を変更しようとします。それはうまくいくかもしれない。この理論をテストするのに適切な環境を用意していないのですが、うまくいくと思うでしょう。 –
barbwire