Thanks, Zheng!

For future reference, this properly picked up the resource with both xslt:
and xslt-saxon, when the pom included both starter dependencies:
.to("xslt-saxon:dummy.xsl?contentCache=False&allowTemplateFromHeader=true")
.to("xslt:dummy.xsl?contentCache=False&allowTemplateFromHeader=true")

It also works fine in the xslt-saxon version when I removed the xslt
starter dependency, keeping this:

<dependency>

<groupId>org.apache.camel.springboot</groupId>

<artifactId>camel-xslt-saxon-starter</artifactId>

<version>4.6.0</version>

<!-- use the same version as your Camel core version -->

</dependency>


And it worked for both header approaches, CamelXsltStylesheet and
CamelXsltResourceUri.

Thanks again!


On Wed, Nov 13, 2024 at 6:06 PM Zheng Feng <zf...@redhat.com> wrote:

> Hi Mitch,
>
> Try this following one and see the
> XsltTemplateFromHeaderOverrideEndpointUriTest.java
> <
> https://github.com/apache/camel/blob/main/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltTemplateFromHeaderOverrideEndpointUriTest.java
> >
>
> .setHeader("CamelXsltStylesheet", simple("file:src/xslt/test.xslt"))
> to("xslt-saxon:dummy.xsl?contentCache=false&allowTemplateFromHeader=true")
>
> On Thu, Nov 14, 2024 at 8:55 AM Mitch Trachtenberg <mjt...@gmail.com>
> wrote:
>
> > Hi,
> >
> > I am able to use xslt-saxon in 4.6.0, specifying a transform as
> > file:src/xslt/test.xslt.
> >
> > I'm using the configuration a few paragraphs below, in Camel 4.6.0, from
> > Eclipse.
> >
> > Given a file uri the xslt takes the incoming XML and, as expected,
> outputs
> > <hello3/>.
> > Given a header of CamelXsltResourceUri set to either
> > constant("file:src/xslt/test.xslt") or simple("file:src/xslt/test.xslt"),
> > with or without adding the prefix xslt-saxon, I get the error that
> follows
> > the configuration code.  I have a similar problem when I put the
> transform
> > itself into the header CamelXsltStylesheet.
> >
> > The docs (for xslt-saxon, despite the use of xslt in the example), say:
> >
> > When using a header for dynamic stylesheet, then you can either refer to
> > the stylesheet as a file or classpath with the header
> CamelXsltResourceUri,
> > such as:
> >
> > from("direct:transform")
> >     .setHeader("CamelXsltResourceUri",
> > simple("file:styles/${header.region}.xsl"))
> >     .to("xslt:template.xsl?allowTemplateFromHeader=true
> >
> >
> > Configuration:
> >
> > @Override
> >
> > public void configure() throws Exception {
> >
> > // TODO Auto-generated method stub
> >
> > from("timer:xslttimer?period=20000")
> >
> > .routeId("xsltRunnerId")
> >
> > .setBody(constant("<?xml version=\"1.0\"
> encoding=\"UTF-8\"?>"+"<Test/>"))
> >
> > .log(LoggingLevel.INFO, "${body}")
> >
> > // I've tried adding xslt-saxon: prior to file:
> >
> > // in setHeader, but neither worked
> >
> > .setHeader(
> >
> > "CamelXsltResourceUri",
> >
> > simple("file:src/xslt/test.xslt"))
> >
> > //.constant("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
> >
> > // + "<xsl:stylesheet version=\"2.0\" xmlns:xsl=\"
> > http://www.w3.org/1999/XSL/Transform\";>"
> >
> > // + " <xsl:template match=\"/\">"
> >
> > // + " <hello3/>"
> >
> > // + " </xsl:template></xsl:stylesheet>")
> >
> > // THIS WORKS WHEN UNCOMMENTED
> >
> > //.to("xslt-saxon:file:src/xslt/test.xslt")
> >
> > // THIS DOES NOT WORK WHEN UNCOMMENTED
> >
> > .to("xslt-saxon?allowTemplateFromHeader=true")
> >
> > .log(LoggingLevel.INFO, "${body}");
> >
> > }
> >
> > }
> >
> >
> > org.apache.camel.FailedToCreateRouteException: Failed to create route
> > xsltRunnerId at:
> >
> > >>> To[xslt-saxon?allowTemplateFromHeader=true] <<<
> >
> > in route: Route(xsltRunnerId)[From[timer:xslttimer?period=20000] ->
> >
> > [S... because of No endpoint could be found for:
> > xslt-saxon?allowTemplateFromHeader=true,
> >
> > please check your classpath contains the needed Camel component jar.
> >
> > at
> >
> org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:234)
> > ~[camel-core-reifier-4.6.0.jar:4.6.0]
> >
> > at
> org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:85)
> > ~[camel-core-reifier-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
> > ~[camel-core-engine-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:728)
> > ~[camel-core-engine-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:594)
> > ~[camel-core-engine-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2391)
> > ~[camel-base-engine-4.6.0.jar:4.6.0]
> >
> > at org.apache.camel.support.service.BaseService.init(BaseService.java:78)
> > ~[camel-api-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2027)
> > ~[camel-base-engine-4.6.0.jar:4.6.0]
> >
> > at
> org.apache.camel.support.service.BaseService.start(BaseService.java:105)
> > ~[camel-api-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2046)
> > ~[camel-base-engine-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:212)
> > ~[camel-core-engine-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:119)
> > ~[camel-spring-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:151)
> > ~[camel-spring-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185)
> > ~[spring-context-6.1.10.jar:6.1.10]
> >
> > at
> >
> >
> org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178)
> > ~[spring-context-6.1.10.jar:6.1.10]
> >
> > at
> >
> >
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156)
> > ~[spring-context-6.1.10.jar:6.1.10]
> >
> > at
> >
> >
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:451)
> > ~[spring-context-6.1.10.jar:6.1.10]
> >
> > at
> >
> >
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:384)
> > ~[spring-context-6.1.10.jar:6.1.10]
> >
> > at
> >
> >
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:984)
> > ~[spring-context-6.1.10.jar:6.1.10]
> >
> > at
> >
> >
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627)
> > ~[spring-context-6.1.10.jar:6.1.10]
> >
> > at
> >
> >
> org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
> > ~[spring-boot-3.2.7.jar:3.2.7]
> >
> > at
> >
> >
> org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
> > ~[spring-boot-3.2.7.jar:3.2.7]
> >
> > at
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
> > ~[spring-boot-3.2.7.jar:3.2.7]
> >
> > at
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
> > ~[spring-boot-3.2.7.jar:3.2.7]
> >
> > at
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1352)
> > ~[spring-boot-3.2.7.jar:3.2.7]
> >
> > at com.jmc.demo.DemoApplication.main(DemoApplication.java:10)
> > ~[classes/:na]
> >
> > Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could be
> > found for: xslt-saxon?allowTemplateFromHeader=true, please check your
> > classpath contains the needed Camel component jar.
> >
> > at
> >
> >
> org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:785)
> > ~[camel-base-engine-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:731)
> > ~[camel-base-engine-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.support.CamelContextHelper.resolveEndpoint(CamelContextHelper.java:128)
> > ~[camel-support-4.6.0.jar:4.6.0]
> >
> > at
> > org.apache.camel.reifier.SendReifier.resolveEndpoint(SendReifier.java:47)
> > ~[camel-core-reifier-4.6.0.jar:4.6.0]
> >
> > at
> > org.apache.camel.reifier.SendReifier.createProcessor(SendReifier.java:37)
> > ~[camel-core-reifier-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:882)
> > ~[camel-core-reifier-4.6.0.jar:4.6.0]
> >
> > at
> >
> >
> org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:622)
> > ~[camel-core-reifier-4.6.0.jar:4.6.0]
> >
> > at
> >
> org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:230)
> > ~[camel-core-reifier-4.6.0.jar:4.6.0]
> >
> > ... 25 common frames omitted
> >
> >
> > I've added the file camel-xslt-saxon-4.6.0.jar
> > <
> >
> https://repo1.maven.org/maven2/org/apache/camel/camel-xslt-saxon/4.6.0/camel-xslt-saxon-4.6.0.jar
> > >
> > to
> > my classpath, fwiw.
> >
> >
> > Any and all suggestions would be welcom.
> >
> >
> > Thanks,
> >
> > Mitch
> >
>

Reply via email to