首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当$variable = $variable时选择XSL

当$variable = $variable时选择XSL
EN

Stack Overflow用户
提问于 2011-09-07 23:28:12
回答 1查看 1.7K关注 0票数 0

我正在尝试检查两个XSL变量是否相同:

代码语言:javascript
复制
<?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="'&#44;'"/> 

<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>&#xD;</xsl:text>

</xsl:for-each>

</xsl:for-each>
</xsl:template>

</xsl:stylesheet>
</file>
</files>

但是,它只是跳过这两个部分,不输出任何内容。

谁能指出我做错了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-09-07 23:55:56

您不能在XSL中“重新声明”变量。当你写的时候

代码语言:javascript
复制
<xsl:variable name="second_check">
  <xsl:value-of select="normalize-space(../../increment_id)"/>
</xsl:variable>

这是没有影响的,因为这个

代码语言:javascript
复制
<xsl:variable name="second_check">0</xsl:variable>

我(目前)帮不了你,因为我真的不确定你想做什么

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7336445

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档