0
濾波器我有以下XSLTXSLT for-each循環的基礎上,可變
<xsl:param name="productsId" select="/macro/productsId" />
<xsl:param name="type" select="/macro/type" /> <!-- value1, value2, value3 -->
<xsl:template match="/">
<xsl:if test="$productsId > 0">
<xsl:variable name="products" select="umbraco.library:GetXmlNodeById($productsId)" />
<div id="carousel-wrap">
<ul id="carousel">
<xsl:for-each select="$products/Product [select only Product with attribute value1, value2 or value3 based on /macro/type]">
<li id="p-{@id}">
<xsl:variable name="title">
<xsl:choose>
<xsl:when test="string-length(productHeading) > 0">
<xsl:value-of select="productHeading" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@nodeName" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="{umbraco.library:NiceUrl(@id)}">
<!-- Image -->
<xsl:if test="productImage > 0">
<xsl:variable name="productImage" select="umbraco.library:GetMedia(productImage, 0)" />
<img src="/ImageGen.ashx?image={$productImage/umbracoFile}&height=131" />
</xsl:if>
<!-- Title -->
<span><xsl:value-of select="$title" disable-output-escaping="yes" /></span>
</a>
</li>
</xsl:for-each>
</ul>
</div>
</xsl:if>
</xsl:template>
基本上,每個產品含有具有真/假值的3個屬性。
value1 = true
value2 = false
value3 = true
現在我將一個參數傳遞給我的樣式表,它將是這些值之一,即value3。
我想選擇所有具有值3設置爲真的節點。沿着線的東西:
<xsl:for-each
select="$products/Product [$type = 'true' (or $type = '1' in XSLT terms)]">
任何想法,這是如何得來的?
+1正確答案。 – 2011-04-18 21:53:13
確實如此,感謝@lwburk! – Marko 2011-04-19 04:00:01