graphstream/gs-core

Error parsing graphml file

Opened this issue · 1 comments

We are using graphstream 2.0 from maven central in a Java 16 project.

Somehow I cannot read a simple graphml file with node attributes. The __characters method within the FileSourceXML#Parser always returns "[Stax Event #4]" as a value although the original double value is 0.0. I tracked it down to this line:

buffer.append(e.asCharacters());

org.codehaus.stax2.ri.evt.CharacterEventImpl.asCharacters() seems to be the wrong method to get the data.

it should be e.getData() or e.mContent

Here is the example graphml (simplified):

<?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">
<key attr.name="EdgeType" attr.type="double" for="edge" id="d2"/>
<key attr.name="G4" attr.type="double" for="node" id="d1"/>
<graph id="G" edgedefault="undirected">
<node id="1">
  <data key="d1">0.0</data>
</node>
<node id="2">
  <data key="d1">2</data>
</node>
<edge id="e1" source="1" target="2">
  <data key="d2">1.0</data>
</edge>
</graph>
</graphml>

And the code for the import:

      FileSource fs = new FileSourceGraphML();
      fs.addSink(graph);
      fs.readAll(file.getAbsolutePath());