How do I access message from <xsl:message> in camel-xslt

Solution In Progress - Updated -

Issue

I'm using

<xsl:message terminate="yes">

to terminate the processing of some xsl stylesheets. The message I put into the tag is outputed to the log but is not contained in the TransformerException that is thrown afterwards. Is there a way to access it from camel route?

For instance, here is my xslt stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>
        <xsl:template match="* | /">
                <xsl:copy>
                        <xsl:apply-templates/>
                </xsl:copy>
        </xsl:template>
        <xsl:template match="age">
                <xsl:choose>
                        <xsl:when test="number(.) &gt; 17">
                                <xsl:copy-of select="."/>
                        </xsl:when>
                        <xsl:otherwise>
                                <xsl:message terminate="yes">
                                        <xsl:text>WARN: the person '</xsl:text>
                                        <xsl:value-of select="/person/name"/>
                                        <xsl:text>' is under 18! age='</xsl:text>
                                        <xsl:value-of select="/person/age"/>
                                        <xsl:text>'</xsl:text>
                                </xsl:message>
                        </xsl:otherwise>
                </xsl:choose>
        </xsl:template>
        <xsl:template match="text() | @*">
                <xsl:copy-of select="."/>
        </xsl:template>
 </xsl:stylesheet>

The following XML will cause the stylesheet to terminate and a warning message to be printed out to the log:

<?xml version="1.0" encoding="UTF-8"?>
<person>
    <name>Jack</name>
    <age>17</age>
 </person>

Environment

  • JBoss Fuse 6.0;
  • JBoss Fuse 6.1;
  • Apache Camel 2.12.x;

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.