editing dia files as XML ...



Thought that some people out here might find this useful ... since
.dia files are basically just XML files, they can be manipulated using
text editing tools. I have always used "replace-string" and
"replace-regexp" in Emacs to do some quick editing, but here's a
little sed trick that is really worth saving somewhere:

sed -i -e '/\"start_arrow\"/,/attribute/ s/val=\"1\"/val=\"22\"/' diagram.dia

I hope that shows up as a single line with only spaces as separators!
What it does, is to change the start arrow of every line in
diagram.dia from style "1" to style "22". You need to do a bit of
experimenting to find out which style is "1" and which is "22". If I
am right, "1" used to be the default arrow one upon a time, while "22"
is the current default arrow (at least it is in my current Ubuntu
setup). I used this script to "upgrade" all my old diagrams to the
current arrow style, which looks better.

For more information on what that script means, read the following
link. In short, this script changes the value assigned to every
"dia:attribute" tag with name "start_arrow".

http://www.grymoire.com/Unix/Sed.html#uh-29

Here's another example that changes the text size for all objects size
"1.2", whatever may be the original size.

sed -i -e '/\"height\"/,/attribute/ s/val=\".*\"/val=\"1.2\"/' diagrams.dia

Note:
1) Use this at your own risk.
2) This works only if you save dia files in an uncompressed format.
There's probably a very simple trick for making it work with
compressed files, but I havn't tried. Heck, it might even just work,
but like I said, I havn't tried.
-- 
Research Scholar, Department of CSE, IIT Bombay
http://www.it.iitb.ac.in/~sameerds/



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