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



On Mon, 4 Apr 2005, Luc Pionchon wrote:

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.

Hi!

Yeah, I realized it was not 'too' complex... You could even use word to
really do a mail merge ;)


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.

I am using "var_variable-name_var". I guess that should be OK?


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.

Yeah, this is where I thought the complexity would come in. Using an XSLT
I guess you could generate a new diagram using the 'rules' of the
transformation, given the variables (a bit like an auto layout), but that
is totally beyond me.

It dosn't matter, because I am just using labels (of determinate maximum
length), which dance around on a fixed diagram. What I would really like
to do is dynamically scale parts of the diagram given the values in my
database, for example, the width of an arrow could represent the size of a
variable, or the size of a box (i.e. a database schematic showing the
number of records in the table by the size of the box). For this reason a
tool to hook up variables and then play around with the possible values to
observe the effects would be ace - but a lot of work for a developer (i.e.
not me).


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$"

Cool :) So you can auto timestamp your diagrams!

Anywhere to post the diagrams and script when I am done? Perhaps it could
be usefull for someone.

Cheers,
Dan.




luc





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