您可以使用变量来实现:
<xsl:variable name="titles" select="../destination/@title"/>
<!--now "titles" contains a nodeset with all the titles -->
<xsl:for-each select="../../../../fieldmaps/field[@name=$titles]">
<!-- you process each field with a name contained inside the titles nodeset -->
</xsl:for-each>
这里有一个简化的例子:
输入:
<parent>
<fieldmaps>
<field name="One"/>
<field name="Two"/>
<field name="Three"/>
</fieldmaps>
<destinations>
<destination title="One"/>
<destination title="Two"/>
</destinations>
</parent>
模板:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- ++++++++++++++++++++++++++++++++ -->
<xsl:template match="parent">
<Results>
<xsl:variable name="titles" select="destinations/destination/@title"/>
<xsl:for-each select="fieldmaps/field[@name=$titles]">
<Result title="{@name}"/>
</xsl:for-each>
</Results>
</xsl:template>
<!-- ++++++++++++++++++++++++++++++++ -->
</xsl:stylesheet>
输出:
<Results>
<Result title="One"/>
<Result title="Two"/>
</Results>
我希望这有帮助!