cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT Cancel print if certain condition

former_member616895
Participant
0 Kudos

Hi all,

in an A4 print template I want to cancel the printing if a certain condition applies. I found xsl:message with the parameter terminate:yes, but using that one this error is written:

javax.xml.transform.TransformerException: java.lang.RuntimeException: Nicht unterst├╝tztes XSL-Element "http://www.w3.org/1999/XSL/Transform:else" (not supported xsl-Element).

Is there another way to cancel the printing / print processing? I am aware that an error in CCO might be shown, that is not a problem.

Thanks

Kai

View Entire Topic
JoergAldinger
Active Contributor

Hello k.schittko

Your error message suggests you were using an "xsl:else" element. However, that element does not exist.

You may alternatively try the following (inverted if condition)

<xsl:if test="condition">
    <xsl:message terminate="yes">Print cancelled due to condition</xsl:message>
</xsl:if>
<xsl:if test="not(condition)">
<!-- the rest of your document -->
</xsl:if>

Or this (choose... otherwise):

<xsl:choose>
<xsl:when test="condition"> <xsl:message terminate="yes">Print cancelled due to condition</xsl:message> </xsl:when>
<xsl:otherwise>
<!-- the rest of your document -->
</xsl:otherwise>
</xsl:choose>

Hope this helps!

Best regards,

Joerg.

former_member616895
Participant
0 Kudos

Hello joerg.ceo,

sometimes it helps to read the error message completely...

I forgot that xsl uses choose and not if-else. This way it will probably work, I'll try it, thanks!