Do I need to write a custom XMLReader for this?

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

Do I need to write a custom XMLReader for this?

noel
Hi everyone!
I have invoice files (1 file/invoice) in a fixed length record format that I need to transform into EDI format. Each line has a three digit header that indicates the data in that line. It kinda looks like this: (description of line data in parenthesis)

050... (Receiver GLN)
100... (Order number)
105... (Order date and order number)
105... (Delivery date and delivery number)
105... (Invoice date and invoice number)
110... (Additional text)
115... (Currency tax)
120... (Buyer GLN)
120... (Delivery destination GLN)
120... (Invoice receiver GLN)
120... (Supplier GLN)
170... (Value date and interest)
200... (Item header[Position, GTIN])
280... (Item details[Supplier number, customer number, price, tax, ...)
200 - another item -
280
200 - another item (obviously there can be more line items in an invoice) -
280
400... (Invoice totals)
500... (Invoice trailer)

I was hoping I could use Smooks for the transformation to EDI but I can't figure out how to configure the fixed length record reader to work with the whole file. Am I correct in the assumption that I have to write a custom XMLReader for this format?
I thought about splitting the file on each line and using a different reader for each line based on the header and then binding all lines to form an invoice model. But I cannot find an example for a transformation using multiple readers and aggregation.
Another way I though of doing this is using Apache Camel for the splitting and aggregation like so: http://camel.apache.org/composed-message-processor.html and then sending the model to smooks for the EDI transformation.

I appreciate your help/advice on this!
Reply | Threaded
Open this post in threaded view
|

Re: Do I need to write a custom XMLReader for this?

Tom Fennelly
You could try using the Regex Reader.  It basically lets you read
anything you can match with a regex.  There should be an example there.

On 26/08/2013 07:14, noel wrote:

> Hi everyone!
> I have invoice files (1 file/invoice) in a fixed length record format that I
> need to transform into EDI format. Each line has a three digit header that
> indicates the data in that line. It kinda looks like this: (description of
> line data in parenthesis)
>
> 050... (Receiver GLN)
> 100... (Order number)
> 105... (Order date and order number)
> 105... (Delivery date and delivery number)
> 105... (Invoice date and invoice number)
> 110... (Additional text)
> 115... (Currency tax)
> 120... (Buyer GLN)
> 120... (Delivery destination GLN)
> 120... (Invoice receiver GLN)
> 120... (Supplier GLN)
> 170... (Value date and interest)
> 200... (Item header[Position, GTIN])
> 280... (Item details[Supplier number, customer number, price, tax, ...)
> 200 - another item -
> 280
> 200 - another item (obviously there can be more line items in an invoice) -
> 280
> 400... (Invoice totals)
> 500... (Invoice trailer)
>
> I was hoping I could use Smooks for the transformation to EDI but I can't
> figure out how to configure the fixed length record reader to work with the
> whole file. Am I correct in the assumption that I have to write a custom
> XMLReader for this format?
> I thought about splitting the file on each line and using a different reader
> for each line based on the header and then binding all lines to form an
> invoice model. But I cannot find an example for a transformation using
> multiple readers and aggregation.
> Another way I though of doing this is using Apache Camel for the splitting
> and aggregation like so:
> http://camel.apache.org/composed-message-processor.html and then sending the
> model to smooks for the EDI transformation.
>
> I appreciate your help/advice on this!
>
>
>
>
> --
> View this message in context: http://milyn.996300.n3.nabble.com/Do-I-need-to-write-a-custom-XMLReader-for-this-tp8664.html
> Sent from the milyn - dev 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: Do I need to write a custom XMLReader for this?

noel
I don't think I will be able to configure the regex reader for this. There are to many variables involved.
Digging in the mailing list I found a thread which has almost exactly the same file format problem:
http://milyn.996300.n3.nabble.com/Re-SV-milyn-user-SV-Smooks-EDI-fixed-length-question-feature-request-td6050i20.html

Unfortunately there is no available outcome/code from that thread :(
Following the same approach an example custom reader config for my file would look like this (simplified):

<medi:segment segcode="050" xmltag="receiver" position="0-3"> 
    <medi:field xmltag="gln"  position="59" length="35"/>
</medi:segment>
<medi:segment segcode="100" xmltag="reference" position="0-3"> 
    <medi:field xmltag="invoice-number" position="15" length="35"/>
</medi:segment>
<medi:segment segcode="105" xmltag="invoice-header" position="0-3"> 
    <medi:field xmltag="header-qualifier" position="6" length="3" matchOn="137"/>
    <medi:field xmltag="date" position="9" length="8"/>
</medi:segment>
<medi:segment segcode="105" xmltag="delivery-header" position="0-3"> 
    <medi:field xmltag="header-qualifier" position="6" length="3" matchOn="171"/>
    <medi:field xmltag="date" position="9" length="8"/>
    <medi:field xmltag="type-qualifier" position="21" length="3" matchOn="DQ "/>
</medi:segment>
<medi:segment segcode="105" xmltag="customer-order-header" position="0-3"> 
    <medi:field xmltag="header-qualifier" position="6" length="3" matchOn="171"/>
    <medi:field xmltag="date" position="9" length="8"/>
    <medi:field xmltag="type-qualifier" position="21" length="3" matchOn="ON "/>
</medi:segment>
<medi:segment segcode="105" xmltag="order-header" position="0-3"> 
    <medi:field xmltag="header-qualifier" position="6" length="3" matchOn="171"/>
    <medi:field xmltag="date" position="9" length="8"/>
    <medi:field xmltag="type-qualifier" position="21" length="3" matchOn="VN "/>
</medi:segment>
...

You get the idea? It's kinda a fixed length EDI format.
Reply | Threaded
Open this post in threaded view
|

Re: Do I need to write a custom XMLReader for this?

Tom Fennelly
Sounds like you'll need to implement a custom reader in that case.

On 27/08/2013 09:40, noel wrote:

> I don't think I will be able to configure the regex reader for this. There
> are to many variables involved.
> Digging in the mailing list I found a thread which has almost exactly the
> same file format problem:
> http://milyn.996300.n3.nabble.com/Re-SV-milyn-user-SV-Smooks-EDI-fixed-length-question-feature-request-td6050i20.html
>
> Unfortunately there is no available outcome/code from that thread :(
> Following the same approach an example custom reader config for my file
> would look like this (simplified):
>
> <medi:segment segcode="050" xmltag="receiver" position="0-3">
>      <medi:field xmltag="gln"  position="59" length="35"/>
> </medi:segment>
> <medi:segment segcode="100" xmltag="reference" position="0-3">
>      <medi:field xmltag="invoice-number" position="15" length="35"/>
> </medi:segment>
> <medi:segment segcode="105" xmltag="invoice-header" position="0-3">
>      <medi:field xmltag="header-qualifier" position="6" length="3"
> matchOn="137"/>
>      <medi:field xmltag="date" position="9" length="8"/>
> </medi:segment>
> <medi:segment segcode="105" xmltag="delivery-header" position="0-3">
>      <medi:field xmltag="header-qualifier" position="6" length="3"
> matchOn="171"/>
>      <medi:field xmltag="date" position="9" length="8"/>
>      <medi:field xmltag="type-qualifier" position="21" length="3" matchOn="DQ
> "/>
> </medi:segment>
> <medi:segment segcode="105" xmltag="customer-order-header" position="0-3">
>      <medi:field xmltag="header-qualifier" position="6" length="3"
> matchOn="171"/>
>      <medi:field xmltag="date" position="9" length="8"/>
>      <medi:field xmltag="type-qualifier" position="21" length="3" matchOn="ON
> "/>
> </medi:segment>
> <medi:segment segcode="105" xmltag="order-header" position="0-3">
>      <medi:field xmltag="header-qualifier" position="6" length="3"
> matchOn="171"/>
>      <medi:field xmltag="date" position="9" length="8"/>
>      <medi:field xmltag="type-qualifier" position="21" length="3" matchOn="VN
> "/>
> </medi:segment>
> ...
>
> You get the idea? It's kinda a fixed length EDI format.
>
>
>
> --
> View this message in context: http://milyn.996300.n3.nabble.com/Do-I-need-to-write-a-custom-XMLReader-for-this-tp8664p8666.html
> Sent from the milyn - dev 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