yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #00135
xml editing
Hello,
I dived into modifying saved .xml states of a
simulation and want to share what I discovered in case
anybody wants to do it as well and as a reminder for
myself.
1) Yade is a bit picky about its XML. It seems to use
a particular self written parser, and not an available
library like expat ? If in the original saved xml the
ending tag is right after the xml attributes as a "
/>" one needs to preserve that. It is not possible to
replace it with a full ending tag "</tagname>" (after
of course also closing the open tag with a >).
This would make producing a readable XML much easier.
2) the body id_s need to be consecutive from 0 to n.
So, after deleting body elements from the xml one
needs to reindex the bodies. Why can't there be any
gaps in the id_s ?
3) the <body size="number"> needs to have the exact
number of bodies. This seems a bit redundant ?
4) the volatileInteraction section can be reduced to
the initial 0 size interaction line. I guess Yade
recalculates the interactions immediately in the first
iteration.
If everything is done crrectly, one just reload the
modified xml and restart the simulation.
The xml is a bit hard to work with, although not
impossible. I guess have to learn more perl or python,
sofar I use awk with xml extensions.
Here are some awk helper scripts:
update bodysize:
BEGIN{i=0;}
{ln[NR]= $0}
$0 ~ /_className_="Body"/ {i++}
$0 ~ /<body size=/ {bs = NR}
END {
ln[bs] = "<body size=\""i"\">"
for (l = 1; l <= FNR; l++) print ln[l]
}
remove volatileInteractions:
BEGIN{sw=0;}
$1 == "<volatileInteractions" {print; sw = 1}
$1 == "</volatileInteractions>" {
print " <interaction size=\"0\" />"; sw = 0}
sw == 0 {print}
_______________________________________________
Yade-users mailing list
Yade-users@xxxxxxxxxxxxxxxx
http://lists.berlios.de/mailman/listinfo/yade-users