我正试图在magento上使用Xtento产品导出生成产品提要,但我无法获得显示第三个位置值的product_type。
你能帮我一下吗?
代码:
<!--product_type -->
<xsl:element name="product_type">
<xsl:choose>
<xsl:when test="string(xtento_mapped_category)"><xsl:value-of select="xtento_mapped_category"/></xsl:when>
<xsl:when test="string(cats/cat[children_count=0]/path_name)">
<xsl:value-of select="substring-after(substring-after(cats/cat[children_count=0]/path_name,'>'),' > ')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-after(substring-after(parent_item/cats/cat[children_count=0]/path_name,'>'),' > ')" />
</xsl:otherwise>
</xsl:choose>
</xsl:element>
输出产品类型:女性>Undies>Thong内衣>全棉通内衣
应该只是";Thong Underwear"或字符串的第3个位置。
给定一个包含以下内容的字符串:
alpha > bravo > charlie > delta
以下表达式:
<xsl:value-of select="substring-before(substring-after(substring-after($your-string, ' > '), ' > '), ' > ')" />
将返回:
charlie
请注意,这假设第三个令牌不是给定字符串的最后一个令牌。如果你不能确定,那么使用:
<xsl:value-of select="substring-before(substring-after(substring-after(concat($your-string, ' > '), ' > '), ' > '), ' > ')" />