-1

我们如何实现以下逻辑。

UniqueID 是临时变量。PALLET_NUMBER 来自输入。

如果 PALLET_NUMBER!=NULL 那么

UniqueID=子字符串 (PALLET_NUMBER, 10)

如果 PALLET_NUMBER =NULL 则

UniqueID=子字符串 (CARTON_NUMBER, 7)

我们可以从上述两个条件中得到UniqueID的值。这些事情发生在迭代循环中。我们如何覆盖UniqueID临时变量。

因为以后有一个条件我们需要放像

<foreach>   
 If previous UniqueID != current UniqueID then

        <Some code>
        <IF>
</foreach>
4

2 回答 2

1

您不能覆盖 xslt 中的变量。

您可能需要查找 xslt 扩展函数来实现您的目标。

于 2013-03-22T09:52:51.393 回答
0

正如 Treemonkey 所说,不可能覆盖变量,但您可以使用递归来实现您所描述的内容:

假设你有这样的事情:

<xsl:for-each select="my/node/isNamed/something" />

你可以这样做:

<xsl:variable name="items" select="my/node/isNamed/something" />
<xsl:apply-templates select="$items[1]">
  <xsl:with-param name="remainder" select="$items[position() > 1" />
</xsl:apply-templates>

<!-- Separate template -->
<xsl:template match="something">
  <xsl:param name="remainder" />
  <xsl:param name="lastId" />

  <xsl:variable name="uniqueId" select="..." />
  <!-- Contents of the xsl:for-each -->

  <xsl:apply-templates select="$remainder[1]">
    <xsl:with-param name="remainder" select="$remainder[position() > 1]" />
    <xsl:with-param name="lastId" select="$uniqueId" />
  </xsl:apply-templates>
</xsl:template>
于 2013-03-22T10:05:09.163 回答