1
我的輸入XML就像下面的部分出現在部分下。根據xslt中的子元素字符串評論父元素
<part type="backmatter">
<section counter="yes" level="1">
<title>Credits<target id="page1301"/></title>
<section counter="yes" level="2">
<title>Chapter 1</title>
<para><link idref="c001_t003">Table 1-3</link> Adapted from Sidle DM</para>
......
......
</section>
</section>
<section counter="yes" level="1">
<title>Index<target id="page1321"/></title>
<section counter="yes" level="2">
<title>A</title>
<listing type="dash">
<litem><para>Abbé lip switch flap</para>
</litem>
<litem><para>Abdomen</para>
......
......
</section>
</section>
</part>
輸出應該是,
<part type="backmatter">
<section counter="yes" level="1">
<title>Credits<target id="page1301"/></title>
<section counter="yes" level="2">
<title>Chapter 1</title>
<para><link idref="c001_t003">Table 1-3</link> Adapted from Sidle DM</para>
......
......
</section>
</section>
<!--<section counter="yes" level="1">
<title>Index<target id="page1321"/></title>
<section counter="yes" level="2">
<title>A</title>
<listing type="dash">
<litem>
<para>Abbé lip switch flap</para></litem>
<litem><para>Abdomen</para>
......
......
</section>
</section>-->
</part>
我的XSLT是,
<xsl:template match="section">
<xsl:choose>
<xsl:when test="following-sibling::title[contains(., 'Index')]">
<xsl:text disable-output-escaping="yes"><!--</xsl:text>
<xsl:copy><xsl:apply-templates select="node() | @*"/> </xsl:copy>
<xsl:text disable-output-escaping="yes">--></xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:copy><xsl:apply-templates select="node() | @*"/> </xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
我要評論 「部分」 只要標題包含 '索引' 的字符串,其餘的部分應該是因爲它在xml中。你能幫我們解決這個問題嗎?