Message transformation using XML in Spring XML config

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Message transformation using XML in Spring XML config

David Siefert-2
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
Reply | Threaded
Open this post in threaded view
|

Re: Message transformation using XML in Spring XML config

jstrachan
On 28/03/2008, David Siefert <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Message transformation using XML in Spring XML config

jstrachan
On 28/03/2008, James Strachan <[hidden email]> wrote:

> On 28/03/2008, David Siefert <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Message transformation using XML in Spring XML config

David Siefert-2
In reply to this post by jstrachan
On Fri, Mar 28, 2008 at 1:44 PM, James Strachan <[hidden email]>
wrote:

> On 28/03/2008, David Siefert <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Message transformation using XML in Spring XML config

David Siefert-2
In reply to this post by jstrachan
On Fri, Mar 28, 2008 at 1:44 PM, James Strachan <[hidden email]>
wrote:

> On 28/03/2008, David Siefert <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Message transformation using XML in Spring XML config

jstrachan
Do you have camel-spring.jar on your classpath?

On 28/03/2008, David Siefert <[hidden email]> wrote:

> On Fri, Mar 28, 2008 at 1:44 PM, James Strachan <[hidden email]>
>  wrote:
>
>
> > On 28/03/2008, David Siefert <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Message transformation using XML in Spring XML config

jstrachan
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 <[hidden email]> wrote:

> Do you have camel-spring.jar on your classpath?
>
>
>  On 28/03/2008, David Siefert <[hidden email]> wrote:
>  > On Fri, Mar 28, 2008 at 1:44 PM, James Strachan <[hidden email]>
>  >  wrote:
>  >
>  >
>  > > On 28/03/2008, David Siefert <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Message transformation using XML in Spring XML config

David Siefert-2
In reply to this post by jstrachan
On Fri, Mar 28, 2008 at 4:00 PM, James Strachan <[hidden email]>
wrote:

> Do you have camel-spring.jar on your classpath?
>
> On 28/03/2008, David Siefert <[hidden email]> wrote:
> > On Fri, Mar 28, 2008 at 1:44 PM, James Strachan <
> [hidden email]>
> >  wrote:
> >
> >
> > > On 28/03/2008, David Siefert <[hidden email]>
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Message transformation using XML in Spring XML config

David Siefert-2
In reply to this post by jstrachan
On Fri, Mar 28, 2008 at 4:00 PM, James Strachan <[hidden email]>
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 <[hidden email]> wrote:
> > Do you have camel-spring.jar on your classpath?
> >
> >
> >  On 28/03/2008, David Siefert <[hidden email]>
> wrote:
> >  > On Fri, Mar 28, 2008 at 1:44 PM, James Strachan <
> [hidden email]>
> >  >  wrote:
> >  >
> >  >
> >  > > On 28/03/2008, David Siefert <[hidden email]>
> 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