Hi List,

A question on XMLAttributeAttribute and Inheritance,

I have a class so:

[XmlRoot(ElementName="DataPacket")]
public abstract class IResponseElement
{
        protected string type;
        [XmlAttribute(AttributeName="packetType")]
        public string ResponseType
        {
                get{return type;}
        }

        public IResponseElement(string type)
        {
                this.type = type;
        }
}

and a sub class like so:
public class ListingPacket: IResponseElement
{

        private ListParams i_Params;
        public ListingPacket():base("ListingPacket")
        {
        }
}

When I use the Serializer it generates the following

<ListingPacket xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; />

The packet is not inheriting its base class attributes, is this correct
or am I looking at something wrongly?

What I'm Looking for is:
<DataPacket packetType="ListingPacket"/>
The Docs say that the XmlAttributeAttribute is Inheritable

This listing packet will/should contain other XmlAttributeAttributes:

public class ListingPacket: IResponseElement
{

        private ListParams i_Params;
        public ListingPacket():base("ListingPacket")
        {
        }

        [XmlAttribute(AttributeName="packetType")]
        public TypeListing Listing
        {
        }
}

What I would like to do is defer the outer definition of the packet to
the abstract base class and have the ListingPacket define its own guts,

Also this Xml is being consumed by internet explorer (Xslt) so I have no
need for the xsd or xsi namespaces, how do I prevent an XmlDocument From
generating namespaces??

Any suggestions would be appreciated.

Regards,

Alan

===================================
This list is hosted by DevelopMentor®  http://www.develop.com
You may be interested in Guerrilla .NET, 24 March 2003, in London
http://www.develop.com/courses/gdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to