1

我正在处理一个不断丢失地址行的 xsl 文档。我已经修复了它,但似乎已经破坏了它试图修复与修复相关的问题。这是我的代码中的一个示例:

.

  <addressLine2>
        <xsl:choose>
            <xsl:when test="number($houseNameNumberNumericCharacterLength) &gt;= number($houseNameNumberNonNumericCharacterLength)">
                <xsl:value-of select="mad:Address/mad:AddressLineTwo"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$addressLineOne"/>
            </xsl:otherwise>                
        </xsl:choose>   
  </addressLine2>
  <addressLine3>
        <xsl:choose>
            <xsl:when test="addressLine2 != '$addressLineOne'">
                <xsl:value-of select="$addressLineThree"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$addressLineTwo"/>
            </xsl:otherwise>
        </xsl:choose>
  </addressLine3>
  <addressLine4>
        <xsl:choose>
            <xsl:when test="addressLine3 = ($addressLineTwo)">
                <xsl:value-of select="$addressLineThree"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="mad:Address/mad:AddressLineFour"/>
            </xsl:otherwise>
        </xsl:choose>
  </addressLine4>

您可以假设 AddressLine2 始终映射到变量 $addressLineOne。AddressLine2 工作正常。我遇到的问题是地址线 3。我测试

when addressLine2 = $addressLineOne然后choose value $addressLineThree

但是地址出来是这样的:

Line1: (mapped from houseNumberHouseName)
Line2: $AddressLineOne
Line3: $AddressLineThree
Line4: /

我需要的是:

Line1: (mapped from houseNumberHouseName)
Line2: $AddressLineOne
Line3: $AddressLineTwo
Line4: $AddressLineThree

当 AddressLine1 不是从 houseNumberHouseName 映射时:

Line1: $AddressLineOne
Line2: $AddressLineTwo
Line3: $AddressLineThree
Line4: /

有人可以指出为什么我的选择不起作用吗?

谢谢

4

1 回答 1

1

也许你可以像这样简化:

<xsl:choose>
    <xsl:when test="number($houseNameNumberNumericCharacterLength) &gt;= number($houseNameNumberNonNumericCharacterLength)">
        <addressLine2><xsl:value-of select="mad:Address/mad:AddressLineTwo"/></addressLine2>
        <addressLine3><xsl:value-of select="$addressLineThree"/></addressLine3>
        <addressLine4><xsl:value-of select="mad:Address/mad:AddressLineFour"/></addressLine4>
    </xsl:when>
    <xsl:otherwise>
        <addressLine2><xsl:value-of select="$addressLineOne"/></addressLine2>
        <addressLine3><xsl:value-of select="$addressLineTwo"/></addressLine3>
        <addressLine4><xsl:value-of select="$addressLineThree"/></addressLine4>
    </xsl:otherwise>                
</xsl:choose>  
于 2013-09-24T09:58:59.020 回答