You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by David Siefert <si...@gmail.com> on 2008/03/28 18:18:57 UTC

Message transformation using XML in Spring XML config

Hello,

Is there an example of using an XSLT in the Spring XML configuration?

I have something like the following:

<route>
  <from uri="..." />
  <to uri="xslt:..." />
  <!-- *but now what?* -->
</route>

The XML Schema says I can only have one <to />.  In the DSL, you would write
from("...").to("xslt:...").to("...") to write the output to a new
destination.

Thanks,

David

Re: Message transformation using XML in Spring XML config

Posted by James Strachan <ja...@gmail.com>.
On 28/03/2008, James Strachan <ja...@gmail.com> wrote:
> On 28/03/2008, David Siefert <si...@gmail.com> wrote:
>  > Hello,
>  >
>  >  Is there an example of using an XSLT in the Spring XML configuration?
>
>
> Yes I've just added one here...
>  http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/XsltTest.java
>
>  the XML is linked below...
>
>
>
>  >  I have something like the following:
>  >
>  >  <route>
>  >   <from uri="..." />
>  >   <to uri="xslt:..." />
>  >   <!-- *but now what?* -->
>
>
> if you have an InOut route (e.g. a WS invocation, a request response
>  over JMS using a JMSReplyTo or via a HTTP POST) then you're done, the
>  result is returned.
>
>  If you are doing one-way messaging, just add another destination for
>  the result. e.g. another <to/>
>
>
>  >  </route>
>  >
>  >  The XML Schema says I can only have one <to />.
>
>
> I don't think it does (or rather maybe thats an old XSD you're looking at?)
>
>  e.g. see the test XML..
>  http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/XsltTest-context.xml

I've just updated the XSLT wiki page with links to these...
http://cwiki.apache.org/CAMEL/xslt.html

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Message transformation using XML in Spring XML config

Posted by David Siefert <si...@gmail.com>.
On Fri, Mar 28, 2008 at 1:44 PM, James Strachan <ja...@gmail.com>
wrote:

> On 28/03/2008, David Siefert <si...@gmail.com> wrote:
> > Hello,
> >
> >  Is there an example of using an XSLT in the Spring XML configuration?
>
> Yes I've just added one here...
>
> http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/XsltTest.java
>
> the XML is linked below...
>
>
> >  I have something like the following:
> >
> >  <route>
> >   <from uri="..." />
> >   <to uri="xslt:..." />
> >   <!-- *but now what?* -->
>
> if you have an InOut route (e.g. a WS invocation, a request response
> over JMS using a JMSReplyTo or via a HTTP POST) then you're done, the
> result is returned.
>
> If you are doing one-way messaging, just add another destination for
> the result. e.g. another <to/>
>
> >  </route>
> >
> >  The XML Schema says I can only have one <to />.
>
> I don't think it does (or rather maybe thats an old XSD you're looking
> at?)
>
> e.g. see the test XML..
>
> http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/XsltTest-context.xml
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>



I am using Camel 1.2.0, here is the schema snippet:

  <xs:complexType name="routeType">
    <xs:complexContent>
      <xs:extension base="tns:processorType">
        <xs:sequence>
          <xs:element ref="tns:interceptor" maxOccurs="unbounded"
minOccurs="0"/>
          <xs:element ref="tns:from" maxOccurs="unbounded" minOccurs="0"/>
          <xs:choice maxOccurs="unbounded" minOccurs="0">
            <xs:element ref="tns:aggregator"/>
            <xs:element ref="tns:bean"/>
            <xs:element ref="tns:catch"/>
            <xs:element ref="tns:choice"/>
            <xs:element ref="tns:when"/>
            <xs:element ref="tns:otherwise"/>
            <xs:element ref="tns:delayer"/>
            <xs:element ref="tns:onException"/>
            <xs:element ref="tns:filter"/>
            <xs:element ref="tns:finally"/>
            <xs:element ref="tns:idempotentConsumer"/>
            <xs:element ref="tns:intercept"/>
            <xs:element ref="tns:marshal"/>
            <xs:element ref="tns:multicast"/>
            <xs:element ref="tns:policy"/>
            <xs:element ref="tns:proceed"/>
            <xs:element ref="tns:process"/>
            <xs:element ref="tns:recipientList"/>
            <xs:element ref="tns:resequencer"/>
            <xs:element ref="tns:route"/>
            <xs:element ref="tns:splitter"/>
            <xs:element ref="tns:thread"/>
            <xs:element ref="tns:throttler"/>
            <xs:element ref="tns:to"/>
            <xs:element ref="tns:try"/>
            <xs:element ref="tns:unmarshal"/>
          </xs:choice>
        </xs:sequence>
        <xs:attribute name="group" type="xs:string"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
It looks right to me (or I could be rusty on my XML Schema skills).  I guess
its just NetBeans misinterpretation (it says "to [1..1]" for child elements
of route).

Sure enough validation passes... figures! :)

Thanks James!

-David

Re: Message transformation using XML in Spring XML config

Posted by David Siefert <si...@gmail.com>.
On Fri, Mar 28, 2008 at 4:00 PM, James Strachan <ja...@gmail.com>
wrote:

> Do you have camel-spring.jar on your classpath?
>
> On 28/03/2008, David Siefert <si...@gmail.com> wrote:
> > On Fri, Mar 28, 2008 at 1:44 PM, James Strachan <
> james.strachan@gmail.com>
> >  wrote:
> >
> >
> > > On 28/03/2008, David Siefert <si...@gmail.com>
> wrote:
> >  > > Hello,
> >  > >
> >  > >  Is there an example of using an XSLT in the Spring XML
> configuration?
> >  >
> >  > Yes I've just added one here...
> >  >
> >  >
> http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/XsltTest.java
> >  >
> >  > the XML is linked below...
> >  >
> >  >
> >  > >  I have something like the following:
> >  > >
> >  > >  <route>
> >  > >   <from uri="..." />
> >  > >   <to uri="xslt:..." />
> >  > >   <!-- *but now what?* -->
> >  >
> >  > if you have an InOut route (e.g. a WS invocation, a request response
> >  > over JMS using a JMSReplyTo or via a HTTP POST) then you're done, the
> >  > result is returned.
> >  >
> >  > If you are doing one-way messaging, just add another destination for
> >  > the result. e.g. another <to/>
> >  >
> >  > >  </route>
> >  > >
> >  > >  The XML Schema says I can only have one <to />.
> >  >
> >  > I don't think it does (or rather maybe thats an old XSD you're
> looking
> >  > at?)
> >  >
> >  > e.g. see the test XML..
> >  >
> >  >
> http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/XsltTest-context.xml
> >  >
> >  >
> >  > --
> >  > James
> >  > -------
> >  > http://macstrac.blogspot.com/
> >  >
> >  > Open Source Integration
> >  > http://open.iona.com
> >  >
> >
> >
> >
> > I seem to be having some trouble with specifying xslt: as an endpoint.
>  I
> >  simplified my problem as much as possible by putting the XSL at the
> root of
> >  the classpath (another words, its not in any package).  So in Maven I
> have:
> >
> >  /trunk
> >   /src
> >     /main
> >       ...
> >     /resources
> >       /META-INF
> >         /spring.xml
> >       /transform.xsl
> >   /test
> >     /main
> >       ...
> >  I use the ClassPathXmlApplicationContext to load spring.xml from
> META-INF
> >  which works fine.  Then I get the following exception when running my
> test
> >  (during test phase):
> >
> >  org.apache.camel.RuntimeCamelException:
> >  org.apache.camel.NoSuchEndpointException: No endpoint could be found
> for:
> >  xslt:transform.xsl
> >
> >  when it tries to process:
> >
> >  <to uri="xslt:transform.xsl" />
> >
> >  Any idea?
> >
> >  Thanks,
> >
> >
> >  David
> >
>
>
> --
>  James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>


camel-spring was not in my list of dependencies (but I did have it part of
my packaging into a SAR).  I added it and it still failed.

-David

Re: Message transformation using XML in Spring XML config

Posted by David Siefert <si...@gmail.com>.
On Fri, Mar 28, 2008 at 4:00 PM, James Strachan <ja...@gmail.com>
wrote:

> You may need to use trunk or the new 1.3.0 RC (I can't remember how
> recently the XSLT endpoint camel along)
>
> On 28/03/2008, James Strachan <ja...@gmail.com> wrote:
> > Do you have camel-spring.jar on your classpath?
> >
> >
> >  On 28/03/2008, David Siefert <si...@gmail.com>
> wrote:
> >  > On Fri, Mar 28, 2008 at 1:44 PM, James Strachan <
> james.strachan@gmail.com>
> >  >  wrote:
> >  >
> >  >
> >  > > On 28/03/2008, David Siefert <si...@gmail.com>
> wrote:
> >  >  > > Hello,
> >  >  > >
> >  >  > >  Is there an example of using an XSLT in the Spring XML
> configuration?
> >  >  >
> >  >  > Yes I've just added one here...
> >  >  >
> >  >  >
> http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/XsltTest.java
> >  >  >
> >  >  > the XML is linked below...
> >  >  >
> >  >  >
> >  >  > >  I have something like the following:
> >  >  > >
> >  >  > >  <route>
> >  >  > >   <from uri="..." />
> >  >  > >   <to uri="xslt:..." />
> >  >  > >   <!-- *but now what?* -->
> >  >  >
> >  >  > if you have an InOut route (e.g. a WS invocation, a request
> response
> >  >  > over JMS using a JMSReplyTo or via a HTTP POST) then you're done,
> the
> >  >  > result is returned.
> >  >  >
> >  >  > If you are doing one-way messaging, just add another destination
> for
> >  >  > the result. e.g. another <to/>
> >  >  >
> >  >  > >  </route>
> >  >  > >
> >  >  > >  The XML Schema says I can only have one <to />.
> >  >  >
> >  >  > I don't think it does (or rather maybe thats an old XSD you're
> looking
> >  >  > at?)
> >  >  >
> >  >  > e.g. see the test XML..
> >  >  >
> >  >  >
> http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/XsltTest-context.xml
> >  >  >
> >  >  >
> >  >  > --
> >  >  > James
> >  >  > -------
> >  >  > http://macstrac.blogspot.com/
> >  >  >
> >  >  > Open Source Integration
> >  >  > http://open.iona.com
> >  >  >
> >  >
> >  >
> >  >
> >  > I seem to be having some trouble with specifying xslt: as an
> endpoint.  I
> >  >  simplified my problem as much as possible by putting the XSL at the
> root of
> >  >  the classpath (another words, its not in any package).  So in Maven
> I have:
> >  >
> >  >  /trunk
> >  >   /src
> >  >     /main
> >  >       ...
> >  >     /resources
> >  >       /META-INF
> >  >         /spring.xml
> >  >       /transform.xsl
> >  >   /test
> >  >     /main
> >  >       ...
> >  >  I use the ClassPathXmlApplicationContext to load spring.xml from
> META-INF
> >  >  which works fine.  Then I get the following exception when running
> my test
> >  >  (during test phase):
> >  >
> >  >  org.apache.camel.RuntimeCamelException:
> >  >  org.apache.camel.NoSuchEndpointException: No endpoint could be found
> for:
> >  >  xslt:transform.xsl
> >  >
> >  >  when it tries to process:
> >  >
> >  >  <to uri="xslt:transform.xsl" />
> >  >
> >  >  Any idea?
> >  >
> >  >  Thanks,
> >  >
> >  >
> >  >  David
> >  >
> >
> >
> >
> > --
> >
> > James
> >  -------
> >  http://macstrac.blogspot.com/
> >
> >  Open Source Integration
> >  http://open.iona.com
> >
>
>
> --
>  James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>


I'll give it a shot...

-David

Re: Message transformation using XML in Spring XML config

Posted by James Strachan <ja...@gmail.com>.
You may need to use trunk or the new 1.3.0 RC (I can't remember how
recently the XSLT endpoint camel along)

On 28/03/2008, James Strachan <ja...@gmail.com> wrote:
> Do you have camel-spring.jar on your classpath?
>
>
>  On 28/03/2008, David Siefert <si...@gmail.com> wrote:
>  > On Fri, Mar 28, 2008 at 1:44 PM, James Strachan <ja...@gmail.com>
>  >  wrote:
>  >
>  >
>  > > On 28/03/2008, David Siefert <si...@gmail.com> wrote:
>  >  > > Hello,
>  >  > >
>  >  > >  Is there an example of using an XSLT in the Spring XML configuration?
>  >  >
>  >  > Yes I've just added one here...
>  >  >
>  >  > http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/XsltTest.java
>  >  >
>  >  > the XML is linked below...
>  >  >
>  >  >
>  >  > >  I have something like the following:
>  >  > >
>  >  > >  <route>
>  >  > >   <from uri="..." />
>  >  > >   <to uri="xslt:..." />
>  >  > >   <!-- *but now what?* -->
>  >  >
>  >  > if you have an InOut route (e.g. a WS invocation, a request response
>  >  > over JMS using a JMSReplyTo or via a HTTP POST) then you're done, the
>  >  > result is returned.
>  >  >
>  >  > If you are doing one-way messaging, just add another destination for
>  >  > the result. e.g. another <to/>
>  >  >
>  >  > >  </route>
>  >  > >
>  >  > >  The XML Schema says I can only have one <to />.
>  >  >
>  >  > I don't think it does (or rather maybe thats an old XSD you're looking
>  >  > at?)
>  >  >
>  >  > e.g. see the test XML..
>  >  >
>  >  > http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/XsltTest-context.xml
>  >  >
>  >  >
>  >  > --
>  >  > James
>  >  > -------
>  >  > http://macstrac.blogspot.com/
>  >  >
>  >  > Open Source Integration
>  >  > http://open.iona.com
>  >  >
>  >
>  >
>  >
>  > I seem to be having some trouble with specifying xslt: as an endpoint.  I
>  >  simplified my problem as much as possible by putting the XSL at the root of
>  >  the classpath (another words, its not in any package).  So in Maven I have:
>  >
>  >  /trunk
>  >   /src
>  >     /main
>  >       ...
>  >     /resources
>  >       /META-INF
>  >         /spring.xml
>  >       /transform.xsl
>  >   /test
>  >     /main
>  >       ...
>  >  I use the ClassPathXmlApplicationContext to load spring.xml from META-INF
>  >  which works fine.  Then I get the following exception when running my test
>  >  (during test phase):
>  >
>  >  org.apache.camel.RuntimeCamelException:
>  >  org.apache.camel.NoSuchEndpointException: No endpoint could be found for:
>  >  xslt:transform.xsl
>  >
>  >  when it tries to process:
>  >
>  >  <to uri="xslt:transform.xsl" />
>  >
>  >  Any idea?
>  >
>  >  Thanks,
>  >
>  >
>  >  David
>  >
>
>
>
> --
>
> James
>  -------
>  http://macstrac.blogspot.com/
>
>  Open Source Integration
>  http://open.iona.com
>


-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Message transformation using XML in Spring XML config

Posted by James Strachan <ja...@gmail.com>.
Do you have camel-spring.jar on your classpath?

On 28/03/2008, David Siefert <si...@gmail.com> wrote:
> On Fri, Mar 28, 2008 at 1:44 PM, James Strachan <ja...@gmail.com>
>  wrote:
>
>
> > On 28/03/2008, David Siefert <si...@gmail.com> wrote:
>  > > Hello,
>  > >
>  > >  Is there an example of using an XSLT in the Spring XML configuration?
>  >
>  > Yes I've just added one here...
>  >
>  > http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/XsltTest.java
>  >
>  > the XML is linked below...
>  >
>  >
>  > >  I have something like the following:
>  > >
>  > >  <route>
>  > >   <from uri="..." />
>  > >   <to uri="xslt:..." />
>  > >   <!-- *but now what?* -->
>  >
>  > if you have an InOut route (e.g. a WS invocation, a request response
>  > over JMS using a JMSReplyTo or via a HTTP POST) then you're done, the
>  > result is returned.
>  >
>  > If you are doing one-way messaging, just add another destination for
>  > the result. e.g. another <to/>
>  >
>  > >  </route>
>  > >
>  > >  The XML Schema says I can only have one <to />.
>  >
>  > I don't think it does (or rather maybe thats an old XSD you're looking
>  > at?)
>  >
>  > e.g. see the test XML..
>  >
>  > http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/XsltTest-context.xml
>  >
>  >
>  > --
>  > James
>  > -------
>  > http://macstrac.blogspot.com/
>  >
>  > Open Source Integration
>  > http://open.iona.com
>  >
>
>
>
> I seem to be having some trouble with specifying xslt: as an endpoint.  I
>  simplified my problem as much as possible by putting the XSL at the root of
>  the classpath (another words, its not in any package).  So in Maven I have:
>
>  /trunk
>   /src
>     /main
>       ...
>     /resources
>       /META-INF
>         /spring.xml
>       /transform.xsl
>   /test
>     /main
>       ...
>  I use the ClassPathXmlApplicationContext to load spring.xml from META-INF
>  which works fine.  Then I get the following exception when running my test
>  (during test phase):
>
>  org.apache.camel.RuntimeCamelException:
>  org.apache.camel.NoSuchEndpointException: No endpoint could be found for:
>  xslt:transform.xsl
>
>  when it tries to process:
>
>  <to uri="xslt:transform.xsl" />
>
>  Any idea?
>
>  Thanks,
>
>
>  David
>


-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Message transformation using XML in Spring XML config

Posted by David Siefert <si...@gmail.com>.
On Fri, Mar 28, 2008 at 1:44 PM, James Strachan <ja...@gmail.com>
wrote:

> On 28/03/2008, David Siefert <si...@gmail.com> wrote:
> > Hello,
> >
> >  Is there an example of using an XSLT in the Spring XML configuration?
>
> Yes I've just added one here...
>
> http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/XsltTest.java
>
> the XML is linked below...
>
>
> >  I have something like the following:
> >
> >  <route>
> >   <from uri="..." />
> >   <to uri="xslt:..." />
> >   <!-- *but now what?* -->
>
> if you have an InOut route (e.g. a WS invocation, a request response
> over JMS using a JMSReplyTo or via a HTTP POST) then you're done, the
> result is returned.
>
> If you are doing one-way messaging, just add another destination for
> the result. e.g. another <to/>
>
> >  </route>
> >
> >  The XML Schema says I can only have one <to />.
>
> I don't think it does (or rather maybe thats an old XSD you're looking
> at?)
>
> e.g. see the test XML..
>
> http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/XsltTest-context.xml
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>


I seem to be having some trouble with specifying xslt: as an endpoint.  I
simplified my problem as much as possible by putting the XSL at the root of
the classpath (another words, its not in any package).  So in Maven I have:

/trunk
  /src
    /main
      ...
    /resources
      /META-INF
        /spring.xml
      /transform.xsl
  /test
    /main
      ...
I use the ClassPathXmlApplicationContext to load spring.xml from META-INF
which works fine.  Then I get the following exception when running my test
(during test phase):

org.apache.camel.RuntimeCamelException:
org.apache.camel.NoSuchEndpointException: No endpoint could be found for:
xslt:transform.xsl

when it tries to process:

<to uri="xslt:transform.xsl" />

Any idea?

Thanks,

David

Re: Message transformation using XML in Spring XML config

Posted by James Strachan <ja...@gmail.com>.
On 28/03/2008, David Siefert <si...@gmail.com> wrote:
> Hello,
>
>  Is there an example of using an XSLT in the Spring XML configuration?

Yes I've just added one here...
http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/XsltTest.java

the XML is linked below...


>  I have something like the following:
>
>  <route>
>   <from uri="..." />
>   <to uri="xslt:..." />
>   <!-- *but now what?* -->

if you have an InOut route (e.g. a WS invocation, a request response
over JMS using a JMSReplyTo or via a HTTP POST) then you're done, the
result is returned.

If you are doing one-way messaging, just add another destination for
the result. e.g. another <to/>

>  </route>
>
>  The XML Schema says I can only have one <to />.

I don't think it does (or rather maybe thats an old XSD you're looking at?)

e.g. see the test XML..
http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/XsltTest-context.xml


-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com