Re: Create a template diagram (mailmerge-ish)?



Hello,

On Mon, 2005-04-04 at 15:02 +0100, Dan Bolser wrote:
Hi, 

I searched the archives for 'template' but didn't find exactly what I was
looking for.

My idea is to create a basic diagram (a template) with several 'fields' or
variables. Then I need some way to read something like a tab delimited
file and produce one diagram from each 'record' in that file.

The value for each field would be taken from the file and used to
generate a diagram from the template.

Here is a simple example of what I have in mind

+-----+                 +-----+
| $f1 |  <--- $f2 --->  | $f3 |
+-----+                 +-----+

Where $f1 is the text inside the first box, $f2 is the text on an arrow
and $f3 is the text inside the second box. Then using a file
something like...

f1    f2      f3
A     99      B
C     2       D
DAN   LIKES   DIA

I would create 3 diagrams mail merge style.

I guess this is easy for someone who knows what they are doing with XML,
but I am not that person.

Can someone advise?

It would be really great to include a little tool with dia to help do this
kind of 'templating', as their are lots of little things that you could
add to such a system if it were a sub-project rather than a one off hack.

I would find this really useful because I have about 150 little schematics
to draw, and while I would love to use dia I am using GD. (admitedly if I
knew XML better I could generate the dia file directly, but I don't know
how.)

Basically, you do not need to know XML. Just create your diagram, and
use you variable names instead of the text. Then save your diagram
(uncompressed, for text processing). Now use your favourite text
processor (sed, cpp, perl, etc...) and just replace your variable names
by their values.

Note 1: you must however take care that your variable name do not exist
in dia syntax. Using a namespace prefix like BOLSER_VAR_ may be a good
thing to do.

Note 2: You cannot ensure that the layout of your template will be
respected, because you cannot know beforehand the lenght of your values.
And AFAIK some dia objects store their dimensions (is that right?). So
the resuluts may not be wonderful with complex layout templates.


One similar thing that works out of the box is to insert CVS keywords
into your diagram that you store in a CVS repository, on commit cvs
replaces the keywords by their value. So "$Date$" will be replaced by
"$Date 2005/04/04 14:57:32$"


luc
-- 
`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.´¯`·.¸¸.´




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]