You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/06/18 08:17:14 UTC

[camel] branch main updated: CAMEL-18793: add prettyBody to simple language (#10388)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new cc2cd84ddc7 CAMEL-18793: add prettyBody to simple language (#10388)
cc2cd84ddc7 is described below

commit cc2cd84ddc719c194b78f575277b7dd609a3aa7b
Author: Gilvan Filho <gi...@gmail.com>
AuthorDate: Sun Jun 18 05:17:08 2023 -0300

    CAMEL-18793: add prettyBody to simple language (#10388)
---
 core/camel-core-languages/pom.xml                  |  5 ++
 .../modules/languages/pages/simple-language.adoc   |  2 +
 .../camel/language/csimple/CSimpleHelper.java      | 25 ++++++++
 .../simple/ast/SimpleFunctionExpression.java       |  4 ++
 .../apache/camel/language/simple/SimpleTest.java   | 74 ++++++++++++++++++++++
 core/camel-support/pom.xml                         |  4 ++
 .../camel/support/builder/ExpressionBuilder.java   | 38 +++++++++++
 .../pom.xml                                        | 26 ++------
 .../services/org/apache/camel/other.properties     |  7 ++
 .../src/generated/resources/xml-jaxp-util.json     | 15 +++++
 .../apache/camel/util/xml/XmlPrettyPrinter.java    | 18 ++++--
 .../camel/util/xml/XmlPrettyPrinterTest.java       |  0
 .../src/test/resources/log4j2.properties           | 32 ++++++++++
 .../org/apache/camel/util/camel-context.xml        | 49 ++++++++++++++
 core/camel-xml-jaxp/pom.xml                        |  4 ++
 core/pom.xml                                       |  1 +
 parent/pom.xml                                     |  5 ++
 17 files changed, 283 insertions(+), 26 deletions(-)

diff --git a/core/camel-core-languages/pom.xml b/core/camel-core-languages/pom.xml
index bfe667f94e5..13748a89b23 100644
--- a/core/camel-core-languages/pom.xml
+++ b/core/camel-core-languages/pom.xml
@@ -51,6 +51,11 @@
             <artifactId>camel-support</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-xml-jaxp-util</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc
index 1d8f3f13364..82760ae0e2d 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc
@@ -96,6 +96,8 @@ converted body can be null.
 
 |bodyOneLine | String | Converts the body to a String and removes all line-breaks so the string is in one line.
 
+|prettyBody | String | Converts the body to a String, and attempts to pretty print if JSon or XML, otherwise the body is returned as the String value.
+
 |originalBody | Object | The original incoming body (only available if allowUseOriginalMessage=true).
 
 |mandatoryBodyAs(_type_) |Type |Converts the body to the given type determined by its
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleHelper.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleHelper.java
index b44e16dc7fd..983f96cfe76 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleHelper.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleHelper.java
@@ -48,6 +48,8 @@ import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.OgnlHelper;
 import org.apache.camel.util.SkipIterator;
 import org.apache.camel.util.StringHelper;
+import org.apache.camel.util.json.Jsoner;
+import org.apache.camel.util.xml.XmlPrettyPrinter;
 
 /**
  * A set of helper as static imports for the Camel compiled simple language.
@@ -163,6 +165,29 @@ public final class CSimpleHelper {
         return body;
     }
 
+    public static String prettyBody(Exchange exchange) {
+        String body = exchange.getIn().getBody(String.class);
+
+        if (body == null) {
+            return null;
+        } else if (body.startsWith("{") && body.endsWith("}") || body.startsWith("[") && body.endsWith("]")) {
+            body = Jsoner.prettyPrint(body.trim()); //json
+        } else if (body.startsWith("<") && body.endsWith(">")) {
+            return CSimpleHelper.prettyXml(body.trim()); //xml
+        }
+
+        return body;
+    }
+
+    private static String prettyXml(String rawXml) {
+        try {
+            boolean includeDeclaration = rawXml.startsWith("<?xml");
+            return XmlPrettyPrinter.pettyPrint(rawXml, 2, includeDeclaration);
+        } catch (Exception e) {
+            return rawXml;
+        }
+    }
+
     public static Exception exception(Exchange exchange) {
         return LanguageHelper.exception(exchange);
     }
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
index 0ce40d61838..7dbd1b891ff 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
@@ -419,6 +419,8 @@ public class SimpleFunctionExpression extends LiteralExpression {
     private Expression createSimpleExpressionDirectly(CamelContext camelContext, String expression) {
         if (ObjectHelper.isEqualToAny(expression, "body", "in.body")) {
             return ExpressionBuilder.bodyExpression();
+        } else if (ObjectHelper.equal(expression, "prettyBody")) {
+            return ExpressionBuilder.prettyBodyExpression();
         } else if (ObjectHelper.equal(expression, "bodyOneLine")) {
             return ExpressionBuilder.bodyOneLine();
         } else if (ObjectHelper.equal(expression, "originalBody")) {
@@ -826,6 +828,8 @@ public class SimpleFunctionExpression extends LiteralExpression {
     public String createCodeDirectly(String expression) throws SimpleParserException {
         if (ObjectHelper.isEqualToAny(expression, "body", "in.body")) {
             return "body";
+        } else if (ObjectHelper.equal(expression, "prettyBody")) {
+            return "prettyBody(exchange)";
         } else if (ObjectHelper.equal(expression, "bodyOneLine")) {
             return "bodyOneLine(exchange)";
         } else if (ObjectHelper.equal(expression, "id")) {
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index f464d93fcaa..40d4fd8a422 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -1980,6 +1980,80 @@ public class SimpleTest extends LanguageTestSupport {
         assertExpression("Hi ${bodyOneLine} Again", "Hi HelloGreatWorld Again");
     }
 
+    @Test
+    public void testJsonPrettyPrint() throws Exception {
+
+        StringBuilder expectedJson = new StringBuilder();
+        expectedJson.append("{");
+        expectedJson.append(System.lineSeparator());
+        expectedJson.append("\t\"firstName\": \"foo\",");
+        expectedJson.append(System.lineSeparator());
+        expectedJson.append("\t\"lastName\": \"bar\"");
+        expectedJson.append(System.lineSeparator());
+        expectedJson.append("}");
+        expectedJson.append(System.lineSeparator());
+
+        exchange.getIn().setBody("{\"firstName\": \"foo\", \"lastName\": \"bar\"}");
+        assertExpression("${prettyBody}", expectedJson.toString());
+        assertExpression("Hi ${prettyBody}", "Hi " + expectedJson.toString());
+        assertExpression("Hi ${prettyBody} Again", "Hi " + expectedJson.toString() + " Again");
+
+        expectedJson = new StringBuilder();
+        expectedJson.append("[");
+        expectedJson.append(System.lineSeparator());
+        expectedJson.append("\t{");
+        expectedJson.append(System.lineSeparator());
+        expectedJson.append("\t\t\"firstName\": \"foo\",");
+        expectedJson.append(System.lineSeparator());
+        expectedJson.append("\t\t\"lastName\": \"bar\"");
+        expectedJson.append(System.lineSeparator());
+        expectedJson.append("\t},");
+        expectedJson.append(System.lineSeparator());
+        expectedJson.append("\t{");
+        expectedJson.append(System.lineSeparator());
+        expectedJson.append("\t\t\"firstName\": \"foo\",");
+        expectedJson.append(System.lineSeparator());
+        expectedJson.append("\t\t\"lastName\": \"bar\"");
+        expectedJson.append(System.lineSeparator());
+        expectedJson.append("\t}");
+        expectedJson.append(System.lineSeparator());
+        expectedJson.append("]");
+        expectedJson.append(System.lineSeparator());
+
+        exchange.getIn()
+                .setBody("[{\"firstName\": \"foo\", \"lastName\": \"bar\"},{\"firstName\": \"foo\", \"lastName\": \"bar\"}]");
+        assertExpression("${prettyBody}", expectedJson.toString());
+        assertExpression("Hi ${prettyBody}", "Hi " + expectedJson.toString());
+        assertExpression("Hi ${prettyBody} Again", "Hi " + expectedJson.toString() + " Again");
+
+    }
+
+    @Test
+    public void testXMLPrettyPrint() throws Exception {
+        StringBuilder expectedXml = new StringBuilder();
+        expectedXml.append("<person>");
+        expectedXml.append(System.lineSeparator());
+        expectedXml.append("  <firstName>");
+        expectedXml.append(System.lineSeparator());
+        expectedXml.append("    foo");
+        expectedXml.append(System.lineSeparator());
+        expectedXml.append("  </firstName>");
+        expectedXml.append(System.lineSeparator());
+        expectedXml.append("  <lastName>");
+        expectedXml.append(System.lineSeparator());
+        expectedXml.append("    bar");
+        expectedXml.append(System.lineSeparator());
+        expectedXml.append("  </lastName>");
+        expectedXml.append(System.lineSeparator());
+        expectedXml.append("</person>");
+
+        exchange.getIn().setBody("<person><firstName>foo</firstName><lastName>bar</lastName></person>");
+
+        assertExpression("${prettyBody}", expectedXml.toString());
+        assertExpression("Hi ${prettyBody}", "Hi " + expectedXml.toString());
+        assertExpression("Hi ${prettyBody} Again", "Hi " + expectedXml.toString() + " Again");
+    }
+
     @Test
     public void testNestedTypeFunction() throws Exception {
         // when using type: function we need special logic to not lazy evaluate
diff --git a/core/camel-support/pom.xml b/core/camel-support/pom.xml
index ab29756f251..1b5a3eab5dd 100644
--- a/core/camel-support/pom.xml
+++ b/core/camel-support/pom.xml
@@ -55,6 +55,10 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-util-json</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-xml-jaxp-util</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>org.slf4j</groupId>
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java b/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java
index 62a17d94c7e..05766c00e7c 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java
@@ -54,6 +54,8 @@ import org.apache.camel.support.LanguageSupport;
 import org.apache.camel.util.InetAddressUtil;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.StringHelper;
+import org.apache.camel.util.json.Jsoner;
+import org.apache.camel.util.xml.XmlPrettyPrinter;
 
 /**
  * A helper class for working with <a href="http://camel.apache.org/expression.html">expressions</a>.
@@ -2036,4 +2038,40 @@ public class ExpressionBuilder {
         };
     }
 
+    /**
+     * Returns the expression for the message body as pretty formatted string
+     */
+    public static Expression prettyBodyExpression() {
+        return new ExpressionAdapter() {
+            @Override
+            public Object evaluate(Exchange exchange) {
+                String body = exchange.getIn().getBody(String.class);
+
+                if (body == null) {
+                    return null;
+                } else if (body.startsWith("{") && body.endsWith("}") || body.startsWith("[") && body.endsWith("]")) {
+                    return Jsoner.prettyPrint(body); //json
+                } else if(body.startsWith("<") && body.endsWith(">")) {
+                    return ExpressionBuilder.prettyXml(body); //xml
+                }
+
+                return body;
+            }
+
+            @Override
+            public String toString() {
+                return "prettyBody()";
+            }
+        };
+    }
+
+    private static String prettyXml(String rawXml) {
+        try {
+            boolean includeDeclaration = rawXml.startsWith("<?xml");
+            return XmlPrettyPrinter.pettyPrint(rawXml, 2, includeDeclaration);
+        } catch (Exception e) {
+            return rawXml;
+        }
+    }
+
 }
diff --git a/core/camel-xml-jaxp/pom.xml b/core/camel-xml-jaxp-util/pom.xml
similarity index 77%
copy from core/camel-xml-jaxp/pom.xml
copy to core/camel-xml-jaxp-util/pom.xml
index 013ba297494..5f424921bec 100644
--- a/core/camel-xml-jaxp/pom.xml
+++ b/core/camel-xml-jaxp-util/pom.xml
@@ -26,33 +26,17 @@
         <version>4.0.0-SNAPSHOT</version>
     </parent>
 
-    <artifactId>camel-xml-jaxp</artifactId>
+    <artifactId>camel-xml-jaxp-util</artifactId>
     <packaging>jar</packaging>
-    <name>Camel :: XML JAXP</name>
-    <description>Camel XML JAXP</description>
+    <name>Camel :: XML JAXP Util</name>
+    <description>Camel XML JAXP Util</description>
 
     <properties>
-        <firstVersion>3.0.0</firstVersion>
+        <firstVersion>4.0.0</firstVersion>
         <label>core,xml</label>
-        <camel-prepare-component>true</camel-prepare-component>
     </properties>
 
     <dependencies>
-
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-core-model</artifactId>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-support</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-xml-io-util</artifactId>
-        </dependency>
-
         <!-- testing -->
         <dependency>
             <groupId>org.codehaus.woodstox</groupId>
@@ -84,4 +68,4 @@
         </dependency>
     </dependencies>
 
-</project>
+</project>
\ No newline at end of file
diff --git a/core/camel-xml-jaxp-util/src/generated/resources/META-INF/services/org/apache/camel/other.properties b/core/camel-xml-jaxp-util/src/generated/resources/META-INF/services/org/apache/camel/other.properties
new file mode 100644
index 00000000000..2f18ae425fd
--- /dev/null
+++ b/core/camel-xml-jaxp-util/src/generated/resources/META-INF/services/org/apache/camel/other.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+name=xml-jaxp-util
+groupId=org.apache.camel
+artifactId=camel-xml-jaxp-util
+version=4.0.0-SNAPSHOT
+projectName=Camel :: XML JAXP Util
+projectDescription=Camel XML JAXP Util
diff --git a/core/camel-xml-jaxp-util/src/generated/resources/xml-jaxp-util.json b/core/camel-xml-jaxp-util/src/generated/resources/xml-jaxp-util.json
new file mode 100644
index 00000000000..488ff5f4de8
--- /dev/null
+++ b/core/camel-xml-jaxp-util/src/generated/resources/xml-jaxp-util.json
@@ -0,0 +1,15 @@
+{
+  "other": {
+    "kind": "other",
+    "name": "xml-jaxp-util",
+    "title": "Xml Jaxp Util",
+    "description": "Camel XML JAXP Util",
+    "deprecated": false,
+    "firstVersion": "4.0.0",
+    "label": "core,xml",
+    "supportLevel": "Preview",
+    "groupId": "org.apache.camel",
+    "artifactId": "camel-xml-jaxp-util",
+    "version": "4.0.0-SNAPSHOT"
+  }
+}
diff --git a/core/camel-xml-jaxp/src/main/java/org/apache/camel/util/xml/XmlPrettyPrinter.java b/core/camel-xml-jaxp-util/src/main/java/org/apache/camel/util/xml/XmlPrettyPrinter.java
similarity index 93%
rename from core/camel-xml-jaxp/src/main/java/org/apache/camel/util/xml/XmlPrettyPrinter.java
rename to core/camel-xml-jaxp-util/src/main/java/org/apache/camel/util/xml/XmlPrettyPrinter.java
index 0a8724d51b8..89724072545 100644
--- a/core/camel-xml-jaxp/src/main/java/org/apache/camel/util/xml/XmlPrettyPrinter.java
+++ b/core/camel-xml-jaxp-util/src/main/java/org/apache/camel/util/xml/XmlPrettyPrinter.java
@@ -26,8 +26,6 @@ import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
-import static org.apache.camel.util.StringHelper.padString;
-
 public final class XmlPrettyPrinter {
 
     private XmlPrettyPrinter() {
@@ -47,6 +45,16 @@ public final class XmlPrettyPrinter {
         String color(int type, String value);
     }
 
+    /**
+     * Pad the string with leading spaces
+     *
+     * @param level  level
+     * @param blanks number of blanks per level
+     */
+    private static String padString(int level, int blanks) {
+        return " ".repeat(level * blanks);
+    }
+
     public static String colorPrint(String xml, int blanks, boolean declaration, ColorPrintElement color)
             throws Exception {
         return doParse(xml, blanks, declaration, color);
@@ -124,7 +132,7 @@ public final class XmlPrettyPrinter {
 
             @Override
             public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
-                sb.append(padString(indent, blanks));
+                sb.append(XmlPrettyPrinter.padString(indent, blanks));
 
                 StringBuilder lb = new StringBuilder();
                 lb.append("<");
@@ -158,7 +166,7 @@ public final class XmlPrettyPrinter {
                 lb.append(qName);
                 lb.append(">");
 
-                sb.append(padString(indent, blanks));
+                sb.append(XmlPrettyPrinter.padString(indent, blanks));
                 String value = color.color(ColorPrintElement.ELEMENT, lb.toString());
                 sb.append(value);
                 if (indent > 0) {
@@ -172,7 +180,7 @@ public final class XmlPrettyPrinter {
                 System.arraycopy(ch, start, chars, 0, length);
                 String value = color.color(ColorPrintElement.VALUE, new String(chars));
 
-                sb.append(padString(indent, blanks));
+                sb.append(XmlPrettyPrinter.padString(indent, blanks));
                 sb.append(value);
                 sb.append("\n");
             }
diff --git a/core/camel-xml-jaxp/src/test/java/org/apache/camel/util/xml/XmlPrettyPrinterTest.java b/core/camel-xml-jaxp-util/src/test/java/org/apache/camel/util/xml/XmlPrettyPrinterTest.java
similarity index 100%
rename from core/camel-xml-jaxp/src/test/java/org/apache/camel/util/xml/XmlPrettyPrinterTest.java
rename to core/camel-xml-jaxp-util/src/test/java/org/apache/camel/util/xml/XmlPrettyPrinterTest.java
diff --git a/core/camel-xml-jaxp-util/src/test/resources/log4j2.properties b/core/camel-xml-jaxp-util/src/test/resources/log4j2.properties
new file mode 100644
index 00000000000..f518264bf49
--- /dev/null
+++ b/core/camel-xml-jaxp-util/src/test/resources/log4j2.properties
@@ -0,0 +1,32 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+appender.console.type = Console
+appender.console.name = console
+appender.console.layout.type = PatternLayout
+appender.console.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-xml-jaxp-util-test.log
+appender.file.append = true
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+rootLogger.level = INFO
+
+rootLogger.appenderRef.file.ref = file
+#rootLogger.appenderRef.console.ref = console
diff --git a/core/camel-xml-jaxp-util/src/test/resources/org/apache/camel/util/camel-context.xml b/core/camel-xml-jaxp-util/src/test/resources/org/apache/camel/util/camel-context.xml
new file mode 100644
index 00000000000..d111a238942
--- /dev/null
+++ b/core/camel-xml-jaxp-util/src/test/resources/org/apache/camel/util/camel-context.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+  <!-- notice Camel will only update the routes that has been changed, so you can edit either either route or both
+       and save the file, and Camel will update only what is required -->
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+    <route id="timer">
+      <from uri="timer:foo"/>
+      <!-- call the 2nd route -->
+      <to uri="direct:foo"/>
+      <!-- try to change me and save this file -->
+      <log message="You said: ${body}"/>
+    </route>
+
+    <route id="foo">
+      <from uri="direct:foo"/>
+      <!-- try to change me and save this file -->
+      <transform>
+        <constant>Hello World</constant>
+      </transform>
+    </route>
+
+  </camelContext>
+
+</beans>
diff --git a/core/camel-xml-jaxp/pom.xml b/core/camel-xml-jaxp/pom.xml
index 013ba297494..cf6986cee30 100644
--- a/core/camel-xml-jaxp/pom.xml
+++ b/core/camel-xml-jaxp/pom.xml
@@ -48,6 +48,10 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-support</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-xml-jaxp-util</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-xml-io-util</artifactId>
diff --git a/core/pom.xml b/core/pom.xml
index 11ac39b293e..8b5ab07ec5f 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -44,6 +44,7 @@
         <module>camel-base-engine</module>
         <module>camel-xml-io-util</module>
         <module>camel-xml-jaxp</module>
+        <module>camel-xml-jaxp-util</module>
         <module>camel-cluster</module>
         <module>camel-core-engine</module>
         <module>camel-core-languages</module>
diff --git a/parent/pom.xml b/parent/pom.xml
index e29652cea90..e0c48802149 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -653,6 +653,11 @@
                 <artifactId>camel-xml-jaxp</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.apache.camel</groupId>
+                <artifactId>camel-xml-jaxp-util</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>org.apache.camel</groupId>
                 <artifactId>camel-yaml-io</artifactId>