xml to EDI conversion missing UNA field

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

xml to EDI conversion missing UNA field

niels
Hey there,

I currently trying to convert an xml to an EDIFACT document.
The conversion is working for me but I'm still searching how I can configure smooks to also return the `UNA` field?

Can anybody help me out? Is there a possibility to export the UNA field?

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: xml to EDI conversion missing UNA field

niels
I already tried adding the delimiters explicitly to my xml file like this:

<medi:delimiters component=":" escape="?" field="+" segment="'"/>

But without any luck the generated edi document doesn't return the UNA field.

Any other suggestions?
Reply | Threaded
Open this post in threaded view
|

Re: xml to EDI conversion missing UNA field

Tom Fennelly
How are you currently doing things?

On 28/01/2015 09:02, niels wrote:

> I already tried adding the delimiters explicitly to my xml file like this:
>
> <medi:delimiters component=":" escape="?" field="+" segment="'"/>
>
> But without any luck the generated edi document doesn't return the UNA
> field.
>
> Any other suggestions?
>
>
>
> --
> View this message in context: http://milyn.996300.n3.nabble.com/xml-to-EDI-conversion-missing-UNA-field-tp8983p8984.html
> Sent from the milyn - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: xml to EDI conversion missing UNA field

niels
I'm creating a custom camel component.

Here is the code of my component (or the gist https://gist.github.com/cdecb063305c0bc53724.git):

import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultProducer;
import org.milyn.Smooks;
import org.milyn.smooks.edi.unedifact.UNEdifactReaderConfigurator;
 
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.ByteArrayInputStream;
import java.io.StringWriter;
 
public class XmlProducer extends DefaultProducer {
 
    private final Smooks smooks = new Smooks();
 
    public XmlProducer(Endpoint endpoint, Type edifactType) {
        super(endpoint);
        smooks.setReaderConfig(new UNEdifactReaderConfigurator(edifactType.urn()));
    }
 
    @Override
    public void process(Exchange exchange) throws Exception {
        String exchangeBody = exchange.getIn().getBody(String.class);
 
        ByteArrayInputStream edifact = new ByteArrayInputStream(exchangeBody.getBytes());
        StringWriter xml = new StringWriter();
 
        // stream source must be backed by a byte stream
        smooks.filterSource(new StreamSource(edifact), new StreamResult(xml));
 
        exchange.getIn().setBody(xml.toString());
    }
}

Reply | Threaded
Open this post in threaded view
|

Re: xml to EDI conversion missing UNA field

faridtss
This post has NOT been accepted by the mailing list yet.
In reply to this post by niels
Hi Niels,
Currently I am also trying to convert XML to EDI but I am having some issues in doing so. Can you please share a working example.
Thanks.