Simple Port ID attrribute error

I am brand new to GoDiagram and just purchased my copy on Monday. I’ve been able to setup the graphs I need and I am working with the LayoutDemo, as it is the closet to what I need. However, the demo app is based significantly on the MDI design and my app is not an MDI app. So I am trying to work through all of the differences in the demo and apply some of the styles used in the demo to my actual app to generate XML and load the XML back in to regenerate the graph.

I am running into a problem now that I am saving the graphs into XML and then loading them again using the layout demo app. I think that my approach is going to be to start with my app to create the graph, but build a veiwer app starting with the layoutdemo as the base to my viewer. Then build it up from there. So what I am trying to do is to save the XML from my app, then load the XML using the layout demo.
I am having a lot of trouble getting the XML output from my app to match the XML output from the demo app. I copied all of the DemoDocument.IntializeReaderWriter() code and tried to use that to create the same XML output from my app. But when I do so, it does not create the same XML as the layout demo app. Actually it would not even work until I modified it based on code from the user documentation. I'm not sure why it works in the demo app but it does not work in my app. I guess there are other things controlling the settings outside of the initialization routine in the layoutdemo app.
I think I have worked through each problem with the XML except for one. That is what I hope someone can help me with.
My code is generating XML that looks like:
The layoutdemo generates code that looks like:
So it seems that when I load my generated XML using the layoutdemo, it cannot find the port id. All of the nodes show up in the layoutdemo, but there are no connections between them. So I think the port ids being stored as elements in the layout demo and as attributes in mine, is what is causing my XML to not load correctly in the layoutdemo.
What is controlling the node versus attribute of the port and port id? I do see the boolean properties for consume child nodes and another one to create id attributes. I have set them to the same as in the initializereaderwriter() in the layout demo and I have tested every possible pattern to setting them off and on. But the XML generated is not the same. It always puts the port as an attribute of node. I cannot get port to generate as a childnode of node with an id attribute.
What controls the port being created as a seperate childnode with an id attribute?
Why can't I just copy the code from the layout demo demodocument class and use that?
I am leaning to just create the XML from scratch so I have complete control over it. But it looks pretty easy to use the code provided in the layoutdemo, if I can get it to work.
I'm new to this so I am sure I am missing something simple but fundamental here. Any help or suggestions would be very much appreciated.
*****************************
Here's the code that I am using. I basically just coped this over from the LayoutDemo demodocument.IntializeReaderWriter(). But I had to modify it to get it to work for me. Not sure why that is. But this is as close as I can get it to what the LayoutDemo seems to want in order to load the graph from XML.
This is VB.Net. The app was written a few years back in VB and I have not been able to migrate it over to C# just yet. So I have to work with it in VB using the VB version of the layoutDemo as my guide.
Public Sub RegisterTransformers(ByVal rw As GoXmlReaderWriterBase)
Dim doc As GoDocument = New GoDocument() Dim bt As GoXmlBindingTransformer = New GoXmlBindingTransformer("LayoutDemo", doc) bt.AddBinding("version", "Version", GoXmlBindingFlags.RethrowsExceptions) ' let exception from Version setter propogate out bt.AddBinding("name", "Name") rw.AddTransformer(bt) ' Nodes ' create a prototype node 'Dim bln As BasicLayoutNode = New BasicLayoutNode() 'bln.Initialize(New PointF(0, 0), Nothing, 0, True) Dim bn As GoBasicNode = New GoBasicNode() bn.LabelSpot = GoObject.Middle bn.Text = "" bt = New GoXmlBindingTransformer("node", bn) bt.GeneratesPortsAsChildElements = True bt.BodyConsumesChildElements = False bt.IdAttributeUsedForSharedObjects = True bt.HandlesNamedPorts = False bt.AddBinding("horiz", "Horizontal") bt.AddBinding("pos", "Ellipse.Position") bt.AddBinding("pencolor", "Shape.BrushColor") bt.AddBinding("loc", "Location") bt.AddBinding("text", "Text") bt.AddBinding("port", "Port") rw.AddTransformer(bt) ' Ports Dim bp As GoPort = New GoPort() Dim btPorts As GoXmlBindingTransformer = New GoXmlBindingTransformer("port", New GoPort()) btPorts.IdAttributeUsedForSharedObjects = True rw.AddTransformer(bt) ' Links Dim btLinks As GoXmlBindingTransformer = New GoXmlBindingTransformer("link", New GoLink()) btLinks.AddBinding("from", "FromPort") btLinks.AddBinding("to", "ToPort") btLinks.AddBinding("fromarrow", "FromArrow") btLinks.AddBinding("toArrow", "ToArrow") rw.AddTransformer(btLinks) End SubThis is the XML that is being generated from my app using the above code. This will NOT load into the LayoutDemo. The only thing I see different is the horiz attribute and the port element/attribute.
<LayoutDemo name="">
<node id="0" pencolor="-8388608" loc="21.4876251 400" text="root" port="10" />
<node id="1" pencolor="-8388608" loc="108.35611 400" text="XAJXPVR" port="11" />
<node id="2" pencolor="-8388608" loc="217.8255 50" text="XAJXPVR#" port="12" />
<node id="3" pencolor="-8388608" loc="217.8255 150" text="Y2CLMSC" port="13" />
<node id="4" pencolor="-8388608" loc="217.8255 250" text="Y2SNMGC" port="14" />
<node id="5" pencolor="-8388608" loc="217.8255 350" text="YDDSHPR" port="15" />
<node id="6" pencolor="-8388608" loc="217.8255 450" text="YWRTLCI" port="16" />
<node id="7" pencolor="-8388608" loc="217.8255 550" text="Y2CPMSC" port="17" />
<node id="8" pencolor="-8388608" loc="217.8255 650" text="Y2RTJCR" port="18" />
<node id="9" pencolor="-8388608" loc="217.8255 750" text="Y2QLVNR" port="19" />
<link from="10" to="11" fromarrow="false" toArrow="true" />
<link from="11" to="12" fromarrow="false" toArrow="true" />
<link from="11" to="13" fromarrow="false" toArrow="true" />
<link from="11" to="14" fromarrow="false" toArrow="true" />
<link from="11" to="15" fromarrow="false" toArrow="true" />
<link from="11" to="16" fromarrow="false" toArrow="true" />
<link from="11" to="17" fromarrow="false" toArrow="true" />
<link from="11" to="18" fromarrow="false" toArrow="true" />
<link from="11" to="19" fromarrow="false" toArrow="true" />
</LayoutDemo>
Here's what the LayoutDemo is generating when I save XML from it, which of course loads was well.
<LayoutDemo name="GoDemo-TreeViewSample.xml">
- <node id="0" pencolor="-65536" horiz="true" pos="20 7524.925">
<port id="1" />
</node>
What I need to do is figure out what to make the code sample above generate this XML and not the XML sample that I provided.
I did find that "pos" needed to be "loc". That helps, but the arrow lines are still not there. Even if I adjust the XML to match the XML from the layoutdemo, it is still not loading. I am missing something here.

ok… I’m not sure.



this line: bt.AddBinding(“port”, “Port”)



you don’t want.



I’ve taken the LayoutDemo code, and tried to reverse engineer into the state where it doesn’t generate the <port id=> lines, and the only way that I can do that is by



t.GeneratesPortsAsChildElements = false;



but that’s not what you have.



Let me keep looking…

OH!



Under the GoPort transformer, you have



rw.AddTransformer(bt)



you want:



rw.AddTransformer(btPorts)

Ok, I think I finally figured it out. There are two sets of code doing this and I think for the most part I was changing the wrong one, which you would expect that it would not do much! But there are still a few things that are unclear to me.
In the LayoutDemo/demodocument class there is the intializereaderwriter code. How does that get executed? It is private, so something in there fires it. I put a breakpoint on it and it never gets hit.
Because that that, I just copied that code into my class, which I assume is the wrong thing to do. Then I modifed it in my class and called it directly. It is working... sort of. I think I can make a few more changes to get this corrected. But what might be happening is that my version fires, then something else fires the version in demodocument. I copied demodocument from LayoutDemo without ANY changes.
By the way. When I build the XML from strach it works fine in the C# version of LayoutDemo. It does not work in the VB version. I thought that was odd. But I may have done someone to the VB version by accident. But if it doesn't work in the VB version of LayoutDemo, I figured you'd want to know. It doesn;'t work in mine. So I moved to C# and it works fine there, but I had to build the XML from scratch to get the links to show up. But now that I moved things around and I am running the correct code, the links show up.
The shapes are still wrong, but I can figure that out now that I have this part working. Any ideas why my shapes are not coming through? Is the sample code supposed to do that or are there shape transformers as well?
Also, the btPorts was causing problems as well. That was part of the issue. Once I had the correct code running, I made that change and the ports started showing up correctly.