This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 3d502cf6c5 Fixes #3534. Test XSLT extension functions defined in the
application
3d502cf6c5 is described below
commit 3d502cf6c5161c457eb59fd2cc5bb8faddf1de50
Author: James Netherton <[email protected]>
AuthorDate: Mon Oct 26 19:56:20 2026 +0000
Fixes #3534. Test XSLT extension functions defined in the application
Extension function classes no longer need to live in a separate jar, nor be
registered for reflection: XSLTC compiles calls to them into direct method
invocations in the generated translet, which native image reachability
analysis picks up on its own.
Run the extension function test against both a function from the
xslt-support
jar and one defined in the application module, without any reflection
registration, and drop both requirements from the docs.
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../ROOT/pages/reference/extensions/xslt.adoc | 12 +-------
.../xslt/runtime/src/main/doc/configuration.adoc | 12 +-------
...nctionsConfiguration.java => AppFunctions.java} | 11 +++++---
.../quarkus/component/xml/it/XsltResource.java | 6 ++--
.../src/main/resources/application.properties | 2 +-
.../main/resources/xslt/extension-function-app.xsl | 33 ++++++++++++++++++++++
.../camel/quarkus/component/xml/it/XsltTest.java | 7 +++--
7 files changed, 50 insertions(+), 33 deletions(-)
diff --git a/docs/modules/ROOT/pages/reference/extensions/xslt.adoc
b/docs/modules/ROOT/pages/reference/extensions/xslt.adoc
index ec2856c367..a5eb49d154 100644
--- a/docs/modules/ROOT/pages/reference/extensions/xslt.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/xslt.adoc
@@ -111,17 +111,7 @@ These restrictions remain in place when secure-processing
is disabled.
[id="extensions-xslt-configuration-extension-functions-support"]
=== Extension functions support
-Java extension functions do work properly only when:
-
-1. Secure-processing is disabled
-2. Functions are defined in a separate jar
-3. Functions are augmented during native build phase. For example, they can be
registered for reflection:
-[source,java]
-----
-@RegisterForReflection(targets = { my.Functions.class })
-public class FunctionsConfiguration {
-}
-----
+Java extension functions only work when secure-processing is disabled.
[NOTE]
====
diff --git a/extensions/xslt/runtime/src/main/doc/configuration.adoc
b/extensions/xslt/runtime/src/main/doc/configuration.adoc
index cd148684ef..2b10af108a 100644
--- a/extensions/xslt/runtime/src/main/doc/configuration.adoc
+++ b/extensions/xslt/runtime/src/main/doc/configuration.adoc
@@ -58,17 +58,7 @@ and on every transformer it uses, so routes resolve them as
they do on plain Cam
These restrictions remain in place when secure-processing is disabled.
=== Extension functions support
-Java extension functions do work properly only when:
-
-1. Secure-processing is disabled
-2. Functions are defined in a separate jar
-3. Functions are augmented during native build phase. For example, they can be
registered for reflection:
-[source,java]
-----
-@RegisterForReflection(targets = { my.Functions.class })
-public class FunctionsConfiguration {
-}
-----
+Java extension functions only work when secure-processing is disabled.
[NOTE]
====
diff --git
a/integration-test-groups/xml/native/xslt-classpath/src/main/java/org/apache/camel/quarkus/component/xml/it/FunctionsConfiguration.java
b/integration-test-groups/xml/native/xslt-classpath/src/main/java/org/apache/camel/quarkus/component/xml/it/AppFunctions.java
similarity index 78%
rename from
integration-test-groups/xml/native/xslt-classpath/src/main/java/org/apache/camel/quarkus/component/xml/it/FunctionsConfiguration.java
rename to
integration-test-groups/xml/native/xslt-classpath/src/main/java/org/apache/camel/quarkus/component/xml/it/AppFunctions.java
index c44360cfcc..b73972fc5d 100644
---
a/integration-test-groups/xml/native/xslt-classpath/src/main/java/org/apache/camel/quarkus/component/xml/it/FunctionsConfiguration.java
+++
b/integration-test-groups/xml/native/xslt-classpath/src/main/java/org/apache/camel/quarkus/component/xml/it/AppFunctions.java
@@ -16,8 +16,11 @@
*/
package org.apache.camel.quarkus.component.xml.it;
-import io.quarkus.runtime.annotations.RegisterForReflection;
-
-@RegisterForReflection(targets = {
org.apache.camel.quarkus.test.support.xslt.Functions.class })
-public class FunctionsConfiguration {
+/**
+ * An XSLT extension function defined in the application itself rather than in
a separate jar
+ */
+public class AppFunctions {
+ public static String concatDash(String val1, String val2) {
+ return val1 + "-" + val2;
+ }
}
diff --git
a/integration-test-groups/xml/native/xslt-classpath/src/main/java/org/apache/camel/quarkus/component/xml/it/XsltResource.java
b/integration-test-groups/xml/native/xslt-classpath/src/main/java/org/apache/camel/quarkus/component/xml/it/XsltResource.java
index e6568b5ce1..ae4c8bb6b4 100644
---
a/integration-test-groups/xml/native/xslt-classpath/src/main/java/org/apache/camel/quarkus/component/xml/it/XsltResource.java
+++
b/integration-test-groups/xml/native/xslt-classpath/src/main/java/org/apache/camel/quarkus/component/xml/it/XsltResource.java
@@ -99,11 +99,11 @@ public class XsltResource {
String.class);
}
- @Path("/xslt-extension-function")
+ @Path("/xslt-extension-function/{stylesheet}")
@POST
@Produces(MediaType.TEXT_PLAIN)
- public String extensionFunction(String body) {
- return
producerTemplate.requestBody("xslt:xslt/extension-function.xsl", body,
String.class);
+ public String extensionFunction(@PathParam("stylesheet") String
stylesheet, String body) {
+ return producerTemplate.requestBody("xslt:xslt/" + stylesheet +
".xsl", body, String.class);
}
@Path("/xslt-saxon-extension-function")
diff --git
a/integration-test-groups/xml/native/xslt-classpath/src/main/resources/application.properties
b/integration-test-groups/xml/native/xslt-classpath/src/main/resources/application.properties
index 3473652d9c..582a0755ba 100644
---
a/integration-test-groups/xml/native/xslt-classpath/src/main/resources/application.properties
+++
b/integration-test-groups/xml/native/xslt-classpath/src/main/resources/application.properties
@@ -23,5 +23,5 @@
quarkus.log.category."org.apache.camel.quarkus.core.deployment".level = INFO
#
# Quarkus - Camel
#
-quarkus.camel.xslt.sources =
xslt/classpath-transform.xsl,xslt/html-transform.xsl,xslt/html-to-text.xsl,xslt/extension-function.xsl,xslt/include.xsl,xslt/include_not_existing_resource.xsl,xslt/aggregate.xsl,xslt/terminate.xsl
+quarkus.camel.xslt.sources =
xslt/classpath-transform.xsl,xslt/html-transform.xsl,xslt/html-to-text.xsl,xslt/extension-function.xsl,xslt/extension-function-app.xsl,xslt/include.xsl,xslt/include_not_existing_resource.xsl,xslt/aggregate.xsl,xslt/terminate.xsl
quarkus.camel.xslt.features."http\://javax.xml.XMLConstants/feature/secure-processing"
= false
diff --git
a/integration-test-groups/xml/native/xslt-classpath/src/main/resources/xslt/extension-function-app.xsl
b/integration-test-groups/xml/native/xslt-classpath/src/main/resources/xslt/extension-function-app.xsl
new file mode 100644
index 0000000000..5946ec0f0d
--- /dev/null
+++
b/integration-test-groups/xml/native/xslt-classpath/src/main/resources/xslt/extension-function-app.xsl
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ 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.
+
+-->
+<xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
+
xmlns:func='xalan://org.apache.camel.quarkus.component.xml.it.AppFunctions'
+ extension-element-prefixes='func'
+ version='1.0'>
+
+ <xsl:output method="xml" indent="yes" encoding="ISO-8859-1"/>
+
+ <xsl:template match="/">
+ <extension-function-xsl>
+ <xsl:value-of select="func:concatDash(/mail/subject, /mail/body)"
/>
+ </extension-function-xsl>
+ </xsl:template>
+</xsl:stylesheet>
diff --git
a/integration-test-groups/xml/native/xslt-classpath/src/test/java/org/apache/camel/quarkus/component/xml/it/XsltTest.java
b/integration-test-groups/xml/native/xslt-classpath/src/test/java/org/apache/camel/quarkus/component/xml/it/XsltTest.java
index 249b750758..cd1648e7d9 100644
---
a/integration-test-groups/xml/native/xslt-classpath/src/test/java/org/apache/camel/quarkus/component/xml/it/XsltTest.java
+++
b/integration-test-groups/xml/native/xslt-classpath/src/test/java/org/apache/camel/quarkus/component/xml/it/XsltTest.java
@@ -127,11 +127,12 @@ public class XsltTest {
}
}
- @Test
- public void xsltExtensionFunction() {
+ @ParameterizedTest
+ @ValueSource(strings = { "extension-function", "extension-function-app" })
+ public void xsltExtensionFunction(String stylesheet) {
final String actual = RestAssured.given()
.body(BODY)
- .post("/xml/xslt-extension-function")
+ .post("/xml/xslt-extension-function/" + stylesheet)
.then()
.statusCode(200)
.extract().body().asString().trim().replaceAll(">\\s+<", "><");