xsl作用域的问题

上次问了个处理两个xml的xsl问题:
http://community.csdn.net/Expert/topic/3554/3554121.xml?temp=.7769892

现在有关类似的作用域问题:
data.xml:

 1<root>
 2<data a="11" b="22" c="33" d="44"></data>
 3<data a="55" b="66" c="77" d="88"></data>
 4<data a="00" b="99" c="11" d="66"></data>   
 5...   
 6<resouce>
 7<res key="A" value="列头A"></res>
 8<res key="B" value="列头B"></res>
 9<res key="C" value="列头C"></res>   
10...   
11</resouce>
12</root>

filter.xml:

1<filter>
2<col/>C   
3<col/>A   
4</filter>

show.xsl:
..

1<xsl:variable name="_cols" select="document('filter.xml')"></xsl:variable>

...

 1<xsl:template name="buildCols">
 2<tr bgcolor="#CCCCCC">
 3<!--我这里需要从filter里面读取究竟要显示那些列和列的顺序 -->
 4<xsl:for-each select="$_cols/filter/col">
 5<td>
 6<!--下面这一句话有错, 我想做的是filter.xml确定需要显示的列和列的顺序,但是具体列的描述是从data.xml中使用 key到 value的关系显示出来的 -->
 7<xsl:value-of select="/root/resouce/res[@key=col]/@value"></xsl:value-of>
 8<!-- 由于作用域的关系 /root/resouce的计算实际还是从filter.xml取,所以取不出来,不知道怎么搞-->   
 9。。。   
10</td>
11</xsl:for-each>
12</tr>
13</xsl:template>

实际我要输出的是:

列头C ¦ 列头A
33 11
77 55
11 00

请问怎么办?

---------------------------------------------------------------

try

 1<xsl:template name="buildCols">
 2<xsl:variable name="curDoc" select="/"></xsl:variable>
 3<tr bgcolor="#CCCCCC">
 4<xsl:for-each select="$_cols/filter/col">
 5<xsl:variable name="col" select="."></xsl:variable>
 6<td>
 7<xsl:value-of select="$curDoc/root/resouce/res[@key=$col]/@value"></xsl:value-of>   
 8  
 9。。。   
10</td>
11</xsl:for-each>
12</tr>
13</xsl:template>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus