Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing graphml file #363

Open
robinschmid opened this issue Aug 24, 2021 · 1 comment
Open

Error parsing graphml file #363

robinschmid opened this issue Aug 24, 2021 · 1 comment

Comments

@robinschmid
Copy link
Contributor

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

@robinschmid
Copy link
Contributor Author

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());

robinschmid added a commit to robinschmid/gs-core that referenced this issue Nov 13, 2021
Fix NumberFormatException when reading characters. Pass getData() instead of the Characters event.
See graphstream#363
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant