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

Accepted Solutions (1)

Accepted Solutions (1)

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!

Answers (1)

Answers (1)

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

k.schittko

Yes, you can use the xsl:if statement and set the condition you want to check for and the do not execute any other statements if the condition is met. You can also combine the xsl:if statement with an xsl:message in order to make sure that the condition was checked and the print processing was cancelled.

For example:

<xsl:if test="condition">
    <xsl:message terminate="yes">Print cancelled due to condition</xsl:message>
</xsl:if>
former_member616895
Participant
0 Kudos

Hi,

that is exactly what I did. However if there are no other statements outside the xsl:if an empty page is still printed.

Using xsl:message with terminate:yes results in the error message in the question.