My Case:
I'm working on a system that will need to create various X12 files for health care (insurance) transactions and inquiries (Specifically 270 Eligibility and 837 Claim).
I know there are good tools out there (pyx12 specifically) for converting between XML and X12, and actually I've gone as far as importing some components from pyx12 to actually create/manipulate x12 data.
Even considering that, after researching the formats a bit, I'm starting to believe that I could have an easier time generating these formats using a template language. I think that it would be a matter of defining for
loops for any segments&loops that need to be repeated per portion claim/inquiry, and the header regions are going to be somewhat static besides whatever element values that could be easily updated by my context.
Almost all of my records are coming out from sqlalchemy so it should be easy enough to loop through my records in the database where relations are very well defined and mapped.
My questions:
Just a side note:
We're already working with python and django, so that template language is available to us. If we need to do these things as a background process we'll either do the hacky config environment tricks to get django templates to work outside of our django project or else use jinja instead--which is nearly interchangeable.
I haven't worked on x12 specifically, but I've often generated all kinds of textual formats by templating, and I can confirm it works like a charm. I would recommend mako (because it basically gives you all the power of Python for your templating), but if you're keen on staying with django-like templates, then jinja2 is definitely the way to go. Its main advantages include speed, ease of debugging, and a richer templating library, as well as the ease of stand-alone use.