2015-11-05 33 views
1

这里是我的代码:获得内环内外环值与XSLT

<xsl:for-each select="/*/hundreds/hundred"> 
    <div class="page_spacer" /> 
    <div class="page_section" style="{./style}"> 
    <h2><xsl:value-of select="./label"/></h2> 
    <xsl:value-of select="./descriptiontext" /> 
    <button onclick="javascript:window.location.href='{./viewalllink}'"><xsl:value-of select="./label" /></button> 
    <br/> 
    <xsl:for-each select="./contendors/contendor"> 
     <img class="locationthumb" src="/act/locationthumb/{../locid}"/> 
    </xsl:for-each> 
    </div> 
    </xsl:for-each> 

我试图获得来自first loop of hundredslocid值和second loop inside the img element内使用。我想可能../locid会暗示使用父母。

任何帮助将不胜感激。

回答

1

绑定到一个变量:

<xsl:for-each select="/*/hundreds/hundred"> 
    <xsl:variable name="h" select="."/> 
    <div class="page_spacer" /> 
    <div class="page_section" style="{./style}"> 
    <h2><xsl:value-of select="./label"/></h2> 
    <xsl:value-of select="./descriptiontext" /> 
    <button onclick="javascript:window.location.href='{./viewalllink}'"><xsl:value-of select="./label" /></button> 
    <br/> 
    <xsl:for-each select="./contendors/contendor"> 
     <img class="locationthumb" src="/act/locationthumb/{$h/locid}"/> 
    </xsl:for-each> 
    </div> 
    </xsl:for-each>