Basically the email uses XSLT AMPScript to parse XML into the email. Part of the requirement is to count the items in the XML data and perform certain logics based on the item count.
Since XSL uses the XPath to count the item iteration and AMPScript sets the variable with a static field which is then used in the business logics.
For eg: If the item count is more than 10 then the image width and table with will change.
Here is the sample code:
%%[ /*<!--*/ VAR @ItemCount, @WidthTD, @Breaks SET @ItemCount = "<xsl:value-of select='count(message/additional-content/order/order-snapshot/items/item)' />" IF (@ItemCount>9) THEN SET @WidthTD = 37 SET @WidthTB = 300 SET @Breaks = ', ' ELSE SET @WidthTD = 143 SET @WidthTB = 200 SET @Breaks = '<br/>' ENDIF /*-->*/ ]%%
However, the operators '<' and '>' seems to have error within the AMPScript function. My assumption is that the xslt validation is causing the error around the operators. Also the error seems to be fixed if '==' operator is used.
Here is the work around I have got but involves different comparison operators. Below code counts the length of the item counts which is not an ideal solution.
%%[IF (Length(@ItemCount)==2) OR (Length(@ItemCount)==3) THEN SET @WidthTD = 37 ELSE SET @WidthTD = 143 ENDIF]%%
Is there any way of bypassing the validation error around the '<' and '>' operators in AMPScript within XSLT template?
Also here is the error after using the '<' and '>' comparison operators.
The script condition contains an invalid comparison operator. Condition: @ItemCount>=10