- ` by simpler name `M` for example.
I obtained something like:
subgraph cluster_x {
node [label="C"] C_x ;
node [label="E"] E_x ;
node [label="a1"] tag1_x ;
node [label="a2"] tag2_x ;
node [label="R", color="#880000", fillcolor="#880000", fontcolor="white"] R_x ;
R_x -> C_x;
C_x -> tag1_x ;
C_x -> tag2_x ;
R_x -> E_x ;
}
subgraph cluster_y {
node [label="C"] C_y ;
node [label="E"] E_y ;
node [label="a1"] tag1_y ;
node [label="a2"] tag2_y ;
node [label="R", color="#880000", fillcolor="#880000", fontcolor="white"] R_y ;
R_y -> C_y;
C_y -> tag1_y ;
C_y -> tag2_y ;
R_y -> E_y ;
}
subgraph cluster_z {
node [label="C"] C_z ;
node [label="E"] E_z ;
node [label="a1"] tag1_z ;
node [label="a2"] tag2_z ;
node [label="R", color="#880000", style="filled", fillcolor="#880000", fontcolor="white"] R_z ;
R_z -> C_z;
C_z -> tag1_z ;
C_z -> tag2_z ;
R_z -> E_z ;
}
E_x -> R_y ;
E_x -> R_z ;
and
subgraph cluster_x {
node [label="M"] E_x ;
node [label="a1"] tag1_x ;
node [label="V"] value_tag1_x ;
node [label="a2"] tag2_x ;
node [label="V"] value_tag2_x ;
node [label="V", color="#880000", fillcolor="#880000", fontcolor="white"] R_x ;
R_x -> value_tag1_x -> tag1_x ;
R_x -> value_tag2_x -> tag2_x ;
R_x -> E_x ;
}
subgraph cluster_y {
node [label="M"] E_y ;
node [label="a1"] tag1_y ;
node [label="V"] value_tag1_y ;
node [label="a2"] tag2_y ;
node [label="V"] value_tag2_y ;
node [label="V", color="#880000", fillcolor="#880000", fontcolor="white"] R_y ;
R_y -> value_tag1_y -> tag1_y ;
R_y -> value_tag2_y -> tag2_y ;
R_y -> E_y ;
}
subgraph cluster_z {
node [label="M"] E_z ;
node [label="a1"] tag1_z ;
node [label="V"] value_tag1_z ;
node [label="a2"] tag2_z ;
node [label="V"] value_tag2_z ;
node [label="V", color="#880000", fillcolor="#880000", fontcolor="white"] R_z ;
R_z -> value_tag1_z -> tag1_z ;
R_z -> value_tag2_z -> tag2_z ;
R_z -> E_z ;
}
E_x -> R_y ;
E_x -> R_z ;
Then I made myself the following reflexion:
Considering Tree Edit Distance, each unitary transformation of tree correspond to a simple search and replace on my xml source[^nb].
We consider three atomic transformations on trees:
- *substitution*: renaming a node
- *insertion*: adding a node
- *deletion*: remove a node
[^nb]: I did a program which generate automatically the weight in a matrix of each edit distance from data.
One of the particularity of atomic transformations on trees, is ; if you remove a node, all children of this node, became children of its father.
An example:
r - x - a
\ \
\ b
y - c
If you delete the `x` node, you obtain
a
/
r - b
\
y - c
Et regardez ce que ça implique quand on l'écrit en xml :
value for a
value for b
value for c
Then deleting all `x` nodes is equivalent to pass the xml via the following search and replace script:
s/<\/?x>//g
Therefore, if there exists a one state deterministic transducer which transform my trees ;
I can transform the xml from one format to another with just a simple list of search and replace directives.
# Solution
Transform this tree:
R - C - tag1
\ \
\ tag2
E -- R - C - tag1
\ \ \
\ \ tag2
\ E ...
R - C - tag1
\ \
\ tag2
E ...
to this tree:
tag1
/
M - V - M - V - tag2 tag1
\ /
M --- V - tag2
\ \
\ M
\ tag1
\ /
V - tag2
\
M
can be done using the following one state deterministic tree transducer:
> C -> ε
> E -> M
> R -> V
Wich can be traduced by the following simple search and replace directives:
s/C//g
s/E/M/g
s/R/V/g
Once adapted to xml it becomes:
s%?contenu>%%g
s%%- %g
s%
%
%g
s%?rubrique>%