【发布时间】:2017-10-31 05:46:49
【问题描述】:
输入 XML
<section counter="no" type="index">
<title><target id="page417"/>Index</title>
<para>Page numbers in italics represent applications. Page numbers followed by <emph type="italic">f</emph> and <emph type="italic">t</emph> indicate figures and tables, respectively.</para>
<section counter="no">
<title>A</title>
....................
<litem><para>Ammonia/ammonium ion (NH<sub>3</sub>/<!--<inline-figure xlink:href="images/9781604063172_in108.jpg"/>-->)</para>
.....................
</section>
</section>
输出应该是,
<section counter="no" type="index">
<title><target id="page417"/>Index</title>
<para>Page numbers in italics represent applications. Page numbers followed by <emph type="italic">f</emph> and <emph type="italic">t</emph> indicate figures and tables, respectively.</para>
<section counter="no">
<title>A</title>
....................
<litem><para>Ammonia/ammonium ion (NH<sub>3</sub>/<inline-figure xlink:href="images/9781604063172_in108.jpg"/>)</para>
.....................
</section>
我的 xslt 就像,
<xsl:template match="section[@type='index']">
<xsl:if test="contains(.,comment())">
<xsl:copy>
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:copy>
</xsl:if>
</xsl:template>
我们需要根据标题内容删除评论。使用上述 xslt 时,从节点中提取所有内容。输出中只有值可用。请您指导我们。
【问题讨论】:
-
我们需要删除基于
title内容的评论 - 你能在这里分享一下要求吗?您还需要identity template来复制所有内容并将其保留在输出中。这将确保所有节点都在输出中可用。 -
是的..我想删除基于标题的评论。每当标题为“索引”并且 cmets 出现在该指定部分中时,我们需要删除取消注释它。
-
在这种情况下,我们需要注释整个“索引”部分。之前,我们使用这个 xslt 来评论整个部分。
-