I have build a graph in Java which include a swim lane with sub vertices. Encoding this graph produced XML where the edges are before its vertices (for swim lane inner edges). Decoding this graph back results in edges with null target and/or source.

How can I fix this error?

Thanks

asked 28 Nov '12, 09:37

Mohamed's gravatar image

Mohamed
12
accept rate: 0%


Pass the XML document to the mxCodec c'tor.

link

answered 28 Nov '12, 10:45

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

Thanks for your reply but I still get a null

    Document doc = mxXmlUtils.parseXml(mxGraphXML);
    mxCodec codec = new mxCodec(doc);

    mxGraphModel mxModel = (mxGraphModel) codec.decode(doc.getDocumentElement());

And this graph is decoded and encoded again in client side JavaScript library. I have compared both XML from Java and JS and both are identical with different ordering for the cells

Thanks

link

answered 28 Nov '12, 11:03

Mohamed's gravatar image

Mohamed
12
accept rate: 0%

Do the references (source/target) exist in the file (see ID attribute).

link

answered 28 Nov '12, 11:13

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

Yes

I have added the XML from both Java and JS. Edges with null source are 1349968578243, 1349968578251, and 1349968578250. The included XML is just a part that includes all sources/targets in original order (XML before and after the given code are not included)

Original XML from Java (which is decoded correctly)

<mxCell id="1349968578242" parent="1349968578244" style="activity" vertex="1"><Activity as="value" name="ValidateSuccess"/>
<mxGeometry as="geometry" height="42.0" width="95.0" x="116.0" y="115.0"/></mxCell>
<mxCell id="1349968578341" parent="1" style="activity" vertex="1"><Activity as="value" name="AddingRegion" stereotype="Use Case"/>
<mxGeometry as="geometry" height="52.0" width="125.0" x="163.0" y="422.0"/></mxCell>
<mxCell id="1349987126278" parent="1" style="activity" vertex="1"><Activity as="value" name="GetListOfRegions" stereotype="Use Case"/>
<mxGeometry as="geometry" height="50.0" width="120.0" x="846.0" y="424.0"/></mxCell>
<mxCell id="1349968578361" parent="1" style="activity" vertex="1"><Activity as="value" name="DeleteRegion" stereotype="Use Case"/>
<mxGeometry as="geometry" height="52.0" width="125.0" x="567.0" y="422.0"/></mxCell>
<mxCell id="1349968578349" parent="1" style="activity" vertex="1"><Activity as="value" name="DuplicateRegion" stereotype="Use Case"/>
<mxGeometry as="geometry" height="52.0" width="125.0" x="28.0" y="415.0"/></mxCell>
<mxCell id="1349968578244" parent="1" style="region" vertex="1"><Region as="value"/>
<mxGeometry as="geometry" height="172.0" width="562.0" x="241.0" y="117.0"/></mxCell>
<mxCell edge="1" id="1349968578243" parent="1349968578244" source="1349968578236" style="" target="1349968578242"><ActivityEdge as="value"/>
<mxGeometry as="geometry" relative="1"/></mxCell>
<mxCell edge="1" id="1349968578250" parent="1349968578244" source="1349968578248" style="noteconnection" target="1349968578236"><NoteConnection as="value"/>
<mxGeometry as="geometry" relative="1"/></mxCell>
<mxCell edge="1" id="1349968578251" parent="1349968578244" source="1349968578249" style="noteconnection" target="1349968578242"><NoteConnection as="value"/>
<mxGeometry as="geometry" relative="1"/></mxCell>
<mxCell id="1349968578237" parent="1" style="activitystopstate" vertex="1"><ActivityStopState as="value"/>
<mxGeometry as="geometry" height="16.0" width="16.0" x="574.0" y="968.0"/></mxCell>
<mxCell id="1349968578246" parent="1" style="umlnote" vertex="1"><Note as="value" name="loop:10" stereotype="UML"/>
<mxGeometry as="geometry" height="50.0" width="110.0" x="883.0" y="87.0"/></mxCell>
<mxCell id="1349968578333" parent="1" style="activity" vertex="1"><Activity as="value" name="BadRegion" stereotype="Use Case"/>
<mxGeometry as="geometry" height="52.0" width="125.0" x="298.0" y="422.0"/></mxCell>
<mxCell id="1349968578235" parent="1" style="activitystartstate" vertex="1"><ActivityStartState as="value"/>
<mxGeometry as="geometry" height="12.0" width="12.0" x="399.0" y="50.0"/></mxCell>
<mxCell id="1349968578248" parent="1349968578244" style="umlnote" vertex="1"><Note as="value" name="" stereotype="UML"/>
<mxGeometry as="geometry" height="87.0" width="325.0" x="226.0" y="19.0"/></mxCell>
<mxCell id="1349987126216" parent="1" style="activity" vertex="1"><Activity as="value" name="RegionPSites" stereotype="Use Case"/>
<mxGeometry as="geometry" height="52.0" width="120.0" x="706.0" y="422.0"/></mxCell>
<mxCell id="1349968578236" parent="1349968578244" style="activity" vertex="1"><Activity as="value" name="CreateRegion"/>
<mxGeometry as="geometry" height="42.0" width="95.0" x="116.0" y="42.0"/></mxCell>
<mxCell id="1349968578249" parent="1349968578244" style="umlnote" vertex="1"><Note as="value" name="" stereotype="UML"/>
<mxGeometry as="geometry" height="50.0" width="110.0" x="286.0" y="111.0"/></mxCell>

And XML from JS (which has null source)

<mxCell id="1349968578244" style="region" parent="1" vertex="1"><Region as="value"/>
<mxGeometry x="241" y="117" width="562" height="172" as="geometry"/></mxCell>
<mxCell id="1349968578242" style="activity" parent="1349968578244" vertex="1"><Activity name="ValidateSuccess" as="value"/>
<mxGeometry x="116" y="115" width="95" height="42" as="geometry"/></mxCell>
<mxCell id="1349968578243" style="" parent="1349968578244" source="1349968578236" target="1349968578242" edge="1"><ActivityEdge as="value"/>
<mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="1349968578250" style="noteconnection" parent="1349968578244" source="1349968578248" target="1349968578236" edge="1"><NoteConnection as="value"/>
<mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="1349968578251" style="noteconnection" parent="1349968578244" source="1349968578249" target="1349968578242" edge="1"><NoteConnection as="value"/>
<mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="1349968578248" style="umlnote" parent="1349968578244" vertex="1">
<Note name="" stereotype="UML" as="value"/>
<mxGeometry x="226" y="19" width="325" height="87" as="geometry"/></mxCell>
<mxCell id="1349968578236" style="activity" parent="1349968578244" vertex="1"><Activity name="CreateRegion" as="value"/>
<mxGeometry x="116" y="42" width="95" height="42" as="geometry"/></mxCell>
<mxCell id="1349968578249" style="umlnote" parent="1349968578244" vertex="1"><Note name="" stereotype="UML" as="value"/>
<mxGeometry x="286" y="111" width="110" height="50" as="geometry"/></mxCell>

Thanks

link

answered 28 Nov '12, 11:35

Mohamed's gravatar image

Mohamed
12
accept rate: 0%

The above XML works for me in draw.io.

link

answered 29 Nov '12, 03:46

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

Yes, it works in Java Script, but decoding it in Java returns edges with null source for the second XML

link

answered 29 Nov '12, 08:13

Mohamed's gravatar image

Mohamed
12
accept rate: 0%

I tested the following XML in the GraphEditor example for Java (loading it via File, Open):

<mxGraphModel>
  <root>
    <mxCell id="0"/>
    <mxCell id="1" parent="0"/>
    <mxCell id="4" value="" style="endArrow=none" parent="1" source="2" target="3" edge="1">
      <mxGeometry as="geometry"/>
    </mxCell>
    <mxCell id="2" value="" parent="1" vertex="1">
      <mxGeometry x="70" y="60" width="120" height="60" as="geometry"/>
    </mxCell>
    <mxCell id="3" value="" parent="1" vertex="1">
      <mxGeometry x="270" y="60" width="120" height="60" as="geometry"/>
    </mxCell>
  </root>
</mxGraphModel>

This worked for me.

link

answered 05 Dec '12, 16:43

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×5
×5
×2

Asked: 28 Nov '12, 09:37

Seen: 1,657 times

Last updated: 05 Dec '12, 16:43