我正在尝试检查两个XSL变量是否相同:
<?xml version="1.0" encoding="UTF-8"?>
<files>
<file filename="export.csv" path="/export" active="true" ftp="false">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:variable name="quote">"</xsl:variable>
<xsl:variable name="sepstart" select="','"/>
<xsl:template match="/">
<xsl:text>"CustomerID"</xsl:text>
<xsl:variable name="second_check">0</xsl:variable>
<xsl:for-each select="orders/order">
<xsl:for-each select="items/item">
<xsl:variable name="output">
<xsl:variable name="first_check"><xsl:value-of select="normalize-space(../../increment_id)"/></xsl:variable>
<xsl:choose>
<xsl:when test="$first_check = $second_check">
Do something...
</xsl:when>
<xsl:otherwise>
Do something...
<xsl:variable name="second_check"><xsl:value-of select="normalize-space(../../increment_id)"/></xsl:variable>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="$output" />
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</file>
</files>但是,它只是跳过这两个部分,不输出任何内容。
谁能指出我做错了什么?
发布于 2011-09-07 23:55:56
您不能在XSL中“重新声明”变量。当你写的时候
<xsl:variable name="second_check">
<xsl:value-of select="normalize-space(../../increment_id)"/>
</xsl:variable>这是没有影响的,因为这个
<xsl:variable name="second_check">0</xsl:variable>我(目前)帮不了你,因为我真的不确定你想做什么
https://stackoverflow.com/questions/7336445
复制相似问题