我有以下两个XML案例
Case1:
<para>
<phrase>21.001</phrase>
<content-style font-style="italic">Modern wordings.</content-style> The modern
form of the hulls clauses goes back to 1982 and those clauses remain in
widespread use. The Hulls clauses were revised in a number of significant
</para>Case2:
<para>
<phrase>21.146</phrase>
</para>
<para>
<content-style font-style="bold">14.</content-style> Where the ship has stranded,
the insurer is liable for the excepted losses, although the loss is not
attributable to the stranding, provided that when the stranding takes place the
risk has attached and if the policy be on goods, that the damaged goods are
on board.
</para>在这里,我试图检查是否存在following-sibling to phrase, which is child of para,但这里的条件是true,对于这两种情况,条件中的条件应该只适用于Case1。下面是我的XSLT。
<xsl:template name="para" match="para">
<xsl:if test="not(preceding-sibling::para/phrase/following-sibling::node())">
<div>
<xsl:choose>
<xsl:when test="./@align">
<xsl:attribute name="class">
<xsl:text>para align-</xsl:text>
<xsl:value-of select="./@align"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">
<xsl:text>para</xsl:text>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</div>
</xsl:if>
</xsl:template>请让我知道我哪里出了问题,以及如何解决问题。
谢谢
发布于 2014-06-23 13:01:49
如果要选择以下短语的兄弟姐妹,只需使用
phrase/following-sibling::node()当然,只有位于同一个父节点中的节点才会被选中,因为上下文节点是"para“。
https://stackoverflow.com/questions/24365718
复制相似问题