Hi all,
I’m trying to consume some xml and run into some strange behavior.
Some code:
GoDocument doc = new GoDocument();
GoXmlReader reader = new GoXmlReader();
reader.AddTransformer(new TransformModuleNode());
reader.AddTransformer(new TransformModuleNodePort());
reader.AddTransformer(new TransformerDescription());
reader.AddTransformer(new TransformerSize());
reader.AddTransformer(new TransformerPosition());
reader.AddTransformer(new TransformerShape());
reader.RootObject = doc;
StreamReader file = new StreamReader("library.xml");
reader.Consume(file);
class TransformerShape : GoXmlTransformer
{
public TransformerShape()
{
ElementName = “shape”;
TransformerType = typeof(GoObject);
BodyConsumesChildElements = true;
}
public override void ConsumeAttributes(object obj)
{
Debug.WriteLine("TransformerShape.ConsumeAttributes called");
base.ConsumeAttributes(obj);
}
}
The method ConsumeAttributes of my TransformerShape class gets called numerous times, even when there isn’t a element “shape” in the XML. If I change the TransformerType to something else, say a GoBalloon, the ConsumeAttributers method only gets called for each occurrence of a shape element. This is the behavior is what I expect.
To me it looks like the TransformerShape.ConsumeAttributes gets called everytime it encounters a (derived) object of GoObject.
What is going on?
If you need additional information please ask.