You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by tha <th...@opitz-consulting.de> on 2009/03/03 16:42:05 UTC

non-XML to XML transformation

Hello *,

I can't find how it is possible in ServiceMix to transform non-XML data like
fixed-length text, csv files, property files or C/C++Struct dat-files to
XML.

what would be the right component to do so?

in Oracle InterConnect or BEA AquaLogic it can be realized using a
proprietary metadata-language called "D3L" oder "MFL". With that binary/text
data can be described and the transformed to some XML Format. Obviously XSLT
can be  (in a limited way) used to produce such data, but initially
transforming INTO XML seems to be difficult with let's say SAXON.

many thanks for some feedback,
\thomas
-- 
View this message in context: http://www.nabble.com/non-XML-to-XML-transformation-tp22311113p22311113.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: non-XML to XML transformation

Posted by tha <th...@opitz-consulting.de>.
Hi JB,

thank you very much for your quick response.

Could you please go into more detail how engines like Apache Velocity or the
Groovy-scripting could help to transform non-XML to XML data? Both methods
don't really look to me like primarily designed for this use.

Maybe this question is not so much ServiceMix related. It does not seem to
be very complicated to integrate / call-out from ServiceMix to such
transformation frameworks. The question is rather, what non-XML
transformation package/framework would be the right?

What btw is ChainBuilder (which is based on ServiceMix) using for that?

grtx,
\thomas
-- 
View this message in context: http://www.nabble.com/non-XML-to-XML-transformation-tp22311113p22311873.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: non-XML to XML transformation

Posted by jb...@nanthrax.net.
Hi Thomas,

there are several ways to do this :

1/ You can use Camel to make the transformation.
For example, you can use a templating system such as velocity :

public class MyRouteBuilder extends RouteBuilder {
   
   public void configure() throws Exception {
      from("jbi:serviceA").to("velocity:myTransformation.vm").to("jbi:serviceB");
   }

}

Another way is to use a POJO in camel :

public class MyRouteBuilder extends RouteBuilder {
   
   public void configure() throws Exception {
      from("jbi:serviceA").beanRef("myBean", "myTransformationMethod").to("jbi:serviceB");
   }

}

2/ Another solution is to bind a POJO in ServiceMix acting as a transformation service. The routing is performed by JBI :

public class TransformationBean implements MessageExchangeListener {

   @Resource
   private DeliveryChannel channel;

   public void onMessageExchange(MessageExchange exchange) throws MessagingException {
      if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
         NormalizedMessage message = exchange.getMessage("in");
         Source content = message.getContent();
         String body = (new SourceTransformer()).toString(content);
         body = myTransformation(body);
         message.setContent(content);
         exchange.setMessage(message, "out");
         channel.send(exchange);
      }
   }

}

3/ Another solution is to use Groovy scripting via the servicemix-script component

Regards
JB

On Tuesday 03 March 2009 - 07:42, tha wrote:
> 
> Hello *,
> 
> I can't find how it is possible in ServiceMix to transform non-XML data like
> fixed-length text, csv files, property files or C/C++Struct dat-files to
> XML.
> 
> what would be the right component to do so?
> 
> in Oracle InterConnect or BEA AquaLogic it can be realized using a
> proprietary metadata-language called "D3L" oder "MFL". With that binary/text
> data can be described and the transformed to some XML Format. Obviously XSLT
> can be  (in a limited way) used to produce such data, but initially
> transforming INTO XML seems to be difficult with let's say SAXON.
> 
> many thanks for some feedback,
> \thomas
> -- 
> View this message in context: http://www.nabble.com/non-XML-to-XML-transformation-tp22311113p22311113.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>