-
XML data file representing base/derived objects.
I'm working on an XML schema to represent the new data file that our application
currently uses (and two or more of our applications will use in the future).
Most of the design is pretty straight forward, but I'm a little uncertain
what the best approach is for storing data from objects that use inheritance.
As far as I understand the two main approaches would be:
1. Create an element for the base class that contains an element for the
derived class.
2. Create an element for the derived class that contains the element for
the base class.
I believe that option 1 is the best, based on the nature of XML.
For example, if we have a base class mamal and a derived class lion then
you would want a mamal element that contained the lion element. The mamal
element could contain all the info that the base class mamal contained and
the lion element would contain the lion specific info.
Am I correct? Have any of you found this to be more difficult to maintain?
Any input would be greatly appreciated!
dave
-
Re: XML data file representing base/derived objects.
Dave,
It is my opinion that option 2 might be better. After all, the base class
should never know anything about any of its derived classes. Perhaps the
best way would be to add a processing directive to your subclass document
containing a reference to the base class.
Regards,
Mark
"dave" <davesquire2@yahoo.com> wrote:
>
>I'm working on an XML schema to represent the new data file that our application
>currently uses (and two or more of our applications will use in the future).
> Most of the design is pretty straight forward, but I'm a little uncertain
>what the best approach is for storing data from objects that use inheritance.
>
>As far as I understand the two main approaches would be:
>
>1. Create an element for the base class that contains an element for the
>derived class.
>
>2. Create an element for the derived class that contains the element for
>the base class.
>
>I believe that option 1 is the best, based on the nature of XML.
>
>For example, if we have a base class mamal and a derived class lion then
>you would want a mamal element that contained the lion element. The mamal
>element could contain all the info that the base class mamal contained and
>the lion element would contain the lion specific info.
>
>Am I correct? Have any of you found this to be more difficult to maintain?
>
>Any input would be greatly appreciated!
>
>dave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|