Reputation: 716
I am working on an xsl document which keeps loosing lines of an address. I had it fixed but seem to have broken it trying to fix an issue associated with the fix. Here is a sample from my code:
.
<addressLine2>
<xsl:choose>
<xsl:when test="number($houseNameNumberNumericCharacterLength) >= 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>
You can assume AddressLine2 is always mapped to the variable $addressLineOne. AddressLine2 is working fine. The problem I am having is address line 3. I test
when addressLine2 = $addressLineOne
then choose value $addressLineThree
But the address comes out like this:
Line1: (mapped from houseNumberHouseName)
Line2: $AddressLineOne
Line3: $AddressLineThree
Line4: /
What i need is:
Line1: (mapped from houseNumberHouseName)
Line2: $AddressLineOne
Line3: $AddressLineTwo
Line4: $AddressLineThree
and when AddressLine1 is not mapped from houseNumberHouseName:
Line1: $AddressLineOne
Line2: $AddressLineTwo
Line3: $AddressLineThree
Line4: /
Can someone please point out why my choose selects are not working?
Thanks
Upvotes: 1
Views: 146
Reputation: 9577
Perhaps you can simplify like this:
<xsl:choose>
<xsl:when test="number($houseNameNumberNumericCharacterLength) >= 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>
Upvotes: 1