[Chicago] mailmerge for xml?

Cosmin Stejerean cosmin at offbytwo.com
Fri May 1 21:45:55 CEST 2009


On Fri, May 1, 2009 at 2:44 PM, Cosmin Stejerean <cosmin at offbytwo.com>wrote:

> On Fri, May 1, 2009 at 1:51 PM, Lukasz Szybalski <szybalski at gmail.com>wrote:
>
>> Hello,
>> Sorry if its not too related.....but...
>>
>> Does anybody know a documentation that would show how to create  a
>> openoffice template and then fill in the data from an xml?
>>
>> 1. I have an existing xml with a structure
>> 2. I have an existing openoffice document/form
>> 3. I want to fill in information like: Firstname, lastname...etc
>> 4. I want to easly move the xml data to the openoffice form.
>> 5. I will automate the transfer using python uno later on (unless xslt
>> will do it for me)
>>
>> What I'm looking for is a way to define field names in a form that
>> would correspond to a xml. I don't want to translate xml nodes to some
>> field name but I would rather do:
>>
>> xml:
>>     <ClientApp>
>>           <Org>my company</Org>
>>            <Name>Full name of the comapny</Name>
>>           <Version>1.02 (4.02)</Version>
>>       </ClientApp>
>>
>> in my openoffice template create a table and fill it in like this:
>>
>> |   ClientApp.Name       |  ClientApp.Version     |
>>
>>
>> Anybody did anything like that? Its like a mailmerge, but for xml to a
>> form, instead of csv to mailing label.
>>
>
> We've done similar things at work in the past, although we filled
> OpenOffice templates with data from a database. If you're using
> lxml.objectify to translate your XML into an object tree and have some
> flexibility over your ODT layout I would simply use a regex for the
> transformation with some code that looks like
>
> import re
>
> pattern = re.compile('\$\$(.+?)\$\$')
>
>
That pattern assumes you're using $$something$$ for your variable names in
the form so that it's easy to just pick out all of them, change accordingly
or use something else to identify all the things that need to be replaced.

-- 
Cosmin Stejerean
http://offbytwo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20090501/328df076/attachment-0001.htm>


More information about the Chicago mailing list