I am not a programmer and need some help from the pros. If I have more than one validation I want to check for exampel I want this result when test = 78 or 81 otherwise.
I have tried using without succcess
<xsl:variable name = "vatTerm">
<xsl:choose>
<xsl:when test="(DocumentXML/ApplicationObject/Object/CarTypeId!='78') and (CarTypeId!='81')">
<xsl:value-of select="(($netterm $termfee)*$vatrate ) $eptermfeetotalvat"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select ="$eptermfeetotalvat"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Also tried;
<xsl:choose>
<xsl:when test="(DocumentXML/ApplicationObject/Object/CarTypeId!=78">
<xsl:value-of select="(($netterm $termfee)*$vatrate ) $eptermfeetotalvat"/>
</xsl:when>
<xsl:when test="(DocumentXML/ApplicationObject/Object/CarTypeId!=81">
<xsl:value-of select="(($netterm $termfee)*$vatrate ) $eptermfeetotalvat"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select ="$eptermfeetotalvat"/></xsl:otherwise>
</xsl:choose>
CodePudding user response:
You got the DeMorgan right.
But you forgot that the path's base is not duplicated. So, I guess, you should try
<xsl:when test="DocumentXML/ApplicationObject/Object/CarTypeId!='78' and DocumentXML/ApplicationObject/Object/CarTypeId!='81'">
<xsl:value-of select="(($netterm $termfee)*$vatrate ) $eptermfeetotalvat"/>
</xsl:when>
This approach has the restriction that it checks if any CarTypeId
at the given path is unequal to 78 or 81. If you have only one CarTypeId
, this will be working fine with XPath-1.0.
With XPath-2.0 you could simplify and precise this task.
CodePudding user response:
I would use the one predicate like this
<xsl:choose>
<xsl:when test="DocumentXML/ApplicationObject/Object/CarTypeId[.!='78' and .!='81']">
<xsl:value-of select="(($netterm $termfee)*$vatrate ) $eptermfeetotalvat"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select ="$eptermfeetotalvat"/>
</xsl:otherwise>
</xsl:choose>