Hi have a simple graphML file composed of 3 nodes and 2 connections and I would like to convert it so that the internal structure of tags and attribute is differently organized.
The original file is the following:
<?xml version="1.0" encoding="utf-8"?><graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<graph edgedefault="undirected">
<node id="0">
<data key="d0">rBSTS</data>
<data key="d1" />
<data key="d2" />
<data key="d3">n1</data>
<data key="d4" />
</node>
<node id="1">
<data key="d1" />
<data key="d4" />
<data key="d0">rCAC</data>
<data key="d2" />
<data key="d3">n2</data>
</node>
<node id="2">
<data key="d1" />
<data key="d4" />
<data key="d0">rCMF</data>
<data key="d2" />
<data key="d3">n3</data>
</node>
<edge source="0" target="1">
<data key="d5">0.252829037184</data>
</edge>
<edge source="1" target="2">
<data key="d5">0.205407183132</data>
</edge>
</graph>
</graphml>
While the file I would like to obtain is the following (I converted it manually to show the desired result):
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns">
<graph edgedefault="undirected">
<node id="n1">
<data key="dn_href"></data>
<data key="dn_label">rBSTS</data>
<data key="dn_free">rBSTS</data>
<data key="dn_intensityvalue">1</data>
</node>
<node id="n2">
<data key="dn_href"></data>
<data key="dn_label">rCAC</data>
<data key="dn_free">rCAC</data>
<data key="dn_intensityvalue">2</data>
</node>
<node id="n3">
<data key="dn_href"></data>
<data key="dn_label">rCMF</data>
<data key="dn_free">rCMF</data>
<data key="dn_intensityvalue">3</data>
</node>
<edge id="e1_2" source="n1" target="n2">
<data key="de_strength">0.252829037184</data>
</edge>
<edge id="e1_3" source="n2" target="n3">
<data key="de_strength">0.205407183132</data>
</edge>
</graph>
</graphml>
The change of structure is not so easy (e.g. the node ID starts from 0 in the original data structure while it starts from n1 in the desired output): is it possible to convert it by using an XSL transformation?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…