That depends on how you defined TransformNode, and what XML contents you have in the stream/file. Did you set the ElementName and TransformerType properties in your TransformNode constructor?
I don’t know what AddDocument does, but I assume it isn’t relevant to your problem.
Also unrelated to your problem, I assume you have a separate transformer for links, unless you really are only reading in nodes from the XML.
Thanks a lot for your attention.
The XML contents a petri-net diagram data.
The TransformNode looks like processor sample. Moreover, the ElementName and TransformerType are set in constructor.
AddDocument will produce a hashtable.
And, there is a separate transformer for the link.
But I still do not know what is the problem!
So in your application, TransformNode.ElementName == “pnml”?
The “xmlns” attribute will not affect the choice of transformer. (I assume the duplicate “http://” is a typo or else an unusual naming convention.)
Here’s a simple example, that only reads nodes, no links.
The transformer for a GoBasicNode:
internal class SimpleXmlTransformBasicNode : GoXmlTransformer { public SimpleXmlTransformBasicNode() { this.TransformerType = typeof(GoBasicNode); this.ElementName = “node”; this.IdAttributeUsedForSharedObjects = true; }
public override void GenerateAttributes(Object obj) { base.GenerateAttributes(obj); GoBasicNode n = (GoBasicNode)obj; WriteAttrVal(“spot”, n.LabelSpot); WriteAttrVal(“label”, n.Text); WriteAttrVal(“loc”, n.Location); }
public override Object Allocate() { GoBasicNode n = new GoBasicNode(); // you might want to do other common initialization here return n; }
public override void ConsumeAttributes(Object obj) { base.ConsumeAttributes(obj); GoBasicNode n = (GoBasicNode)obj; n.LabelSpot = Int32Attr(“spot”, GoObject.Middle); n.Text = StringAttr(“label”, “”); n.Location = PointFAttr(“loc”, new PointF(100, 100)); } }
The code to use this transformer class:
Stream file = File.Open(…, FileMode.Open); GoXmlReader r = new GoXmlReader(); r.AddTransformer(new SimpleXmlTransformBasicNode()); r.RootObject = myView.Document; r.Consume(file); file.Close();
A sample XML file:
This is one example of program output that I want to read it, it is a little bit diffrent than GoDiagram “processor” sample.
I have the above mentioned codes in my read part of program but it still can not open the file. The open just opens a new empty window.
This example has one place like processor node that it has its own special specifications.