XSLT Saxon
JVM since1.1.0 Native since3.2.0
Transform XML payloads using an XSLT template using Saxon.
What’s inside
-
XSLT Saxon component, URI syntax:
xslt-saxon:resourceUri
Please refer to the above link for usage and configuration details.
Maven coordinates
Or add the coordinates to your existing project:
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-xslt-saxon</artifactId>
</dependency> Check the User guide for more information about writing Camel Quarkus applications.
Usage
Access to external resources from stylesheets
Since Camel 4.22 (Camel Quarkus 3.39.0), the xslt-saxon endpoint sets XMLConstants.ACCESS_EXTERNAL_STYLESHEET to an empty string on the Saxon TransformerFactory. Stylesheets that read external resources, for example via collection() on a file: URI, then fail with an error such as URI scheme 'file' has been disallowed.
To allow the file scheme, configure the factory with a TransformerFactoryConfigurationStrategy bean. Camel calls the strategy after it applies its own security settings, so only the listed schemes are allowed.
import javax.xml.XMLConstants;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Named;
import jakarta.inject.Singleton;
import org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy;
public class XsltSaxonConfig {
@Produces
@Singleton
@Named("allowFileAccess")
TransformerFactoryConfigurationStrategy allowFileAccess() {
return (factory, endpoint) -> factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "file");
}
} Reference the bean from the endpoint:
to("xslt-saxon:file:/path/to/transform.xsl?transformerFactoryConfigurationStrategy=#allowFileAccess") Setting secureProcessing=false does not lift this restriction.