GoXmlWriter

I am using the Eval Version of GoDiagram and trying to write a diagram our to XML.

The following code is called:
GoXmlWriter writer = new GoXmlWriter();
writer.RootElementName = "MethodEditor";
writer.AddTransformer(new TransformNode());
writer.AddTransformer(new TransformLink());
writer.NodesGeneratedFirst = true;
writer.Objects = document;
fileStream = File.Open(@"c:\temp\myShapes.xml", FileMode.Create);
writer.Generate(fileStream);
fileStream.Close();
I always end up with an XML file with nothing but the Root Element.
I set a breakpoint in GenerateAttributes for TransformNode and TransformLink but it never breaks there?
Am I doing something wrong. I am trying to follow the examples in the sample applications that have a Save functionality.
Any help appreciated.

Does the TransformNode constructor assign its TransformerType property to the class of the nodes you have in your document? (And the same applies to TransformLink.)

Yes they do here are the constructors

public TransformNode()
{
this.TransformerType = typeof(MethodEditorNode);
this.ElementName = "node";
this.IdAttributeUsedForSharedObjects = true;
}
public TransformLink()
{
this.TransformerType = typeof(MethodEditorLink);
this.ElementName = "link";
}

That’s odd. I’m assuming you haven’t overidden any methods to skip the generation of XML for your objects.

Well, you could try overriding GoXmlWriter.GenerateObject to see if that's being called for each top-level object in your document.

Maybe I am doing something wrong, this is what I have:

I created a class called MyXml, the constructor takes a GoDocument and assigns it to a private field in MyXML.
This class also has a Save( ) method which is in the original post above.
MyXml xml = new MyXml(View.Document);
xml.Save();
In TransformNode I have overridden GenerateAttributes but it never seens to execute.
Do I need to override the GoXmlWriter? Or are you just suggesting it as a test?

Everything that I have seen looks OK to me, so, yes, I was just suggesting that overriding GoXmlWriter.GenerateObject might be a way to figure out what’s going on.

I created a MyXMLWriter inherited from GoXMLWriter and created the following:

public override void GenerateObject(object obj)
{
base.GenerateObject(obj);
}
I changed MyXml.Save to this:
MyXMLWriter writer = new MyXMLWriter();
writer.RootElementName = "MethodEditor";
writer.AddTransformer(new TransformNode());
writer.AddTransformer(new TransformLink());
writer.NodesGeneratedFirst = true;
writer.Objects = document;
fileStream = File.Open(@"c:\temp\myShapes.xml", FileMode.Create);
writer.Generate(fileStream);
fileStream.Close();
I set a break point in MyXmlWriter.GenerateObject( )
The debugger did not stop on that Break Point when I executed the code.

Hmmm. I guess I have to ask: are you sure the document has nodes in it? What’s the value of GoDocument.Count?

GoXmlWriter.Generate(...) calls GoXmlWriter.GenerateObjects() which iterates over the GoXmlWriter.Objects collection, calling GoXmlWriter.GenerateObject on each object.

You Nailed it.

Although I don't know why. I definatley have objects, but the count is 0.
I must have more documents then I realize, and I'm passing the wrong one.
I'll investigate further.
Thanks for the help. Please pass along any other ideas you might have.

That was the problem. I had my own version of GoDocument and somewhere along the way I ended up passing a wrong instance to the XMl File code.

Thanks for your help, much appreciated.