而不是这样做…
<xsl:comment> CORE TABLES </xsl:comment>
<xsl:apply-templates select="changeSet[createTable/@tableName=$coreTables]"/>
执行此操作,以保存选定的元素
<xsl:variable name="tables" select="changeSet[createTable/@tableName=$coreTables]"/>
<xsl:apply-templates select="$tables" />
其他陈述也是如此。然后,要获取XML中未匹配的元素,可以执行以下操作…
<xsl:apply-templates select="changeSet[not(some $set in ($tables | $sequences | $indexes | $fkeys | $views) satisfies $set is .)]" />
尝试此模板
<xsl:template match="databaseChangeLog">
<xsl:comment> CORE TABLES </xsl:comment>
<xsl:variable name="tables" select="changeSet[createTable/@tableName=$coreTables]"/>
<xsl:apply-templates select="$tables" />
<xsl:comment>CORE SEQUENCES</xsl:comment>
<xsl:variable name="sequences" select="changeSet[createSequence[starts-with(@sequenceName, 'SEQ_') and substring-after(@sequenceName, 'SEQ_') = $coreTables]]"/>
<xsl:apply-templates select="$sequences"/>
<xsl:comment> CORE INDEXES </xsl:comment>
<xsl:variable name="indexes" select="changeSet[createIndex/@tableName=$coreTables]"/>
<xsl:apply-templates select="$indexes"/>
<xsl:comment> CORE FOREIGN CONSTRAINTS </xsl:comment>
<xsl:variable name="fkeys" select="changeSet[addForeignKeyConstraint/@baseTableName=$coreTables]"/>
<xsl:apply-templates select="$fkeys"/>
<xsl:comment> CORE VIEWS </xsl:comment>
<xsl:variable name="views" select="changeSet[addForeignKeyConstraint/@baseTableName=$coreTables]"/>
<xsl:apply-templates select="$views"/>
<xsl:comment> UNMATCHED </xsl:comment>
<xsl:apply-templates select="changeSet[not(some $set in ($tables | $sequences | $indexes | $fkeys | $views) satisfies $set is .)]" />
</xsl:template>
编辑:感谢Martin Honnen,最终的表达式可以简化为…
<xsl:apply-templates select="changeSet except ($tables, $sequences, $indexes, $fkeys, $views)" />