这就是我在 XSL 中尝试做的事情:
<xsl:apply-templates select="document('a.xml')//row"/>
<xsl:apply-templates select="document('b.xml')//row"/>
<xsl:template match="row">
<!-- for document a.xml -->
</xsl:template>
<xsl:template match="row">
<!-- for document b.xml -->
</xsl:template>
由于显而易见的原因,不能像现在这样工作。如何区分这两个模板?文档 a.xml
和 b.xml
在 XML 结构方面完全相同。
最佳答案
使用 mode
attribute .
<xsl:apply-templates select="document('a.xml')//row" mode="a"/>
<xsl:apply-templates select="document('b.xml')//row" mode="b"/>
<xsl:template match="row" mode="a">
<!-- for document a.xml -->
</xsl:template>
<xsl:template match="row" mode="b">
<!-- for document b.xml -->
</xsl:template>
关于xml - 如何区分 XSL 中的两个模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6116912/