使用xslt

时间:2015-11-05 20:56:05

标签: xml variables 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>

我正在尝试从locid获取first loop of hundreds值,并在second loop inside the img element中使用它。我想也许../locid会暗示使用父母。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

将它绑定到变量:

[
{
    "fields": {
        "first_name": "John",
        "last_name": "Doe",
        "middle_name": "G",
        "birthday": "1900-07-21",
        "password": "goforit123",
        "email": "John.Doe@gmail.com"
    },
    "model": "account_data.user",
    "pk": 1  // This is the pk you have to use
},
{
    "fields": {
        "user": 1,  // Use the pk, in this case you're referencing to John Doe
        "type": "dog",
        "color": "blue"
    },
    "model": "account_data.pets",
    "pk": 1
}
]