XSLT2.0 を使用している場合は、トークン化機能を利用できます。
<xsl:variable name="tokenizedValues" select="tokenize($values,',')"/>
これにより、カンマ区切りの文字列が値のリストに分割されます。次に、 name属性がリストにあったことを確認して、テーブル要素を探すことができます
<xsl:apply-templates select="table[index-of($tokenizedValues,@name)]"/>
たとえば、次の XML について考えてみます。
<tables>
<table name="A">1</table>
<table name="B">2</table>
<table name="C">3</table>
<table name="D">4</table>
<table name="E">5</table>
</tables>
以下の XSLT を使用する場合
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/*">
<xsl:variable name="values">A,B,C,D</xsl:variable>
<xsl:variable name="tokenizedValues" select="tokenize($values,',')"/>
<xsl:apply-templates select="table[index-of($tokenizedValues,@name)]"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
次に、以下が出力されます
<table name="A">1</table>
<table name="B">2</table>
<table name="C">3</table>
<table name="D">4</table>