0
輸入xml,如下所示。刪除xslt中只指定父元素而非子元素
<part type="frontmatter">
<section level="1"><title>THIEME Atlas of Anatomy</title>
........
</section>
<section level="1">
<title></title><para><emph type="bold">To access additional material
......
</section>
</part>
<part type="content">
<section level="1">
<title id="p001">Structure and Development of Organ Systems</title>
...
<section level="2">
<title>Suggested Readings</title>
.......
</section>
</section>
</part>
輸出應該是
<part type="frontmatter">
<section level="1"><title>THIEME Atlas of Anatomy</title>
........
</section>
<section level="1">
<title></title><para><emph type="bold">To access additional material
......
</section>
</part>
<part type="content">
<title id="p001">Structure and Development of Organ Systems</title>
...
<section level="2">
<title>Suggested Readings</title>
........
</section>
</part>
我的XSLT是:
<xsl:template match="section[position()=1]"><!-\-//-\->
<xsl:if test="preceding-sibling::part[@type='content'][not(title)]">
<part type="content">
<xsl:apply-templates select="node() | @*"/>
</part>
</xsl:if>
</xsl:template>
我想刪除<section level="1">
元件,其<part type="content">
下出現,其中 「冠軍」 元素不應該在這兩者之間出現元素。如果「標題」出現在部分元素下,則不應做任何更改。
thanku for you response Tim C.下面的代碼工作正常。 xsl:template> –
Sumathi