我有一个要求,只有当其元素之一(sequenceNumber)存在时,才需要考虑节点(节点名称:LineItem),其余所有我们需要删除的LineItems。我在下面尝试过,但是没有用。
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="LineItem[sequenceNumber]"/>
</xsl:stylesheet>``
尝试使用xsl:choose
<xsl:template match="LineItem"/>
<xsl:choose>
<xsl:when test="sequenceNumber">
<!-- create element -->
</xsl:when>
<xsl:otherwise>
<!-- skip element -->
</xsl:otherwise>
<xsl:choose>
我认为您想要的是<xsl:template match="LineItem[sequenceNumber]"/>
,而不是<xsl:template match="LineItem[not(sequenceNumber)]"/>
。>>