Re: XML coding questions

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Dec 02 2004 - 13:13:43 EST

  • Next message: Kevin J. Menard, Jr.: "Re: XML coding questions"

    I agree - any properties shouldbe rooted in the entity that encloses them
    (doesn't matter if this is the main or a dependent entity). As for the
    other question about the order of dependent objects instantiation... there
    can be different possibilities. One is to do it in constructor (would make
    sense for an internal HashMap), another one is to create it on demand
    before setting the property (e.g. if a dependent is a DataObject)...

    By the way, I am about to start a project that does a lot of heavy-duty
    XML encoding-decoding... So I am really looking forward to using this
    feature.

    Andrus

    > On Thu, 2004-12-02 at 08:59, Kevin J. Menard, Jr. wrote:
    >> Hi,
    >>
    >> As some of you know, I'm working on an implementation of the
    >> WOXMLCoder/Decoder system for Cayenne. Work has been progressing
    >> along fairly well as I have time. I am running into a bit of a
    >> logical issue with regards to the model file though that I'm hoping
    >> someone more familiar with the system might be able to answer.
    >>
    >> The first entity block is for the object being encoded, and each
    >> subsequent one for helper objects. Are the property items specified
    >> in these subsequent entities referring to the base object or the
    >> helper one?
    >>
    >> E.g., in the mapping file below:
    >>
    >> <model>
    >> <entity name="Test" xmlTag="Test">
    >> <property name="name" xmlTag="statusId"/>
    >> <property name="address" xmlTag="itemIdentifier"/>
    >> <property name="phone" xmlTag="PriorityId"/>
    >> <property name="map.key" xmlTag="embedded"/>
    >> <property name="user" xmlTag="ownedBy"/>
    >> </entity>
    >> <entity name="User" xmlTag="ownedBy">
    >> <property name="user.name" xmlTag="ownerName"/>
    >> <property name="user.password" xmlTag="clearance"/>
    >> </entity>
    >> </model>
    >>
    >
    > I havent used WOXMLCoder/Decoder for ages, but I think it should look
    > like the following,
    >
    > <model>
    > <entity name="Test" xmlTag="Test">
    > <property name="name" xmlTag="statusId"/>
    > <property name="address" xmlTag="itemIdentifier"/>
    > <property name="phone" xmlTag="PriorityId"/>
    > <property name="map.key" xmlTag="embedded"/>
    > <property name="user" xmlTag="ownedBy"/>
    > </entity>
    > <entity name="User" xmlTag="ownedBy">
    > <property name="name" xmlTag="ownerName"/>
    > <property name="password" xmlTag="clearance"/>
    > </entity>
    > </model>
    >
    > this would encode to,
    >
    > <Test>
    > <ownedBy>
    > <ownerName>kevin</ownerName>
    > <clearance>secret</clearance>
    > </ownedBy>
    > </Test>
    >
    > That would make sense to me... but then again some may say I'm not very
    > sensible. :)
    >
    >>
    >> "user", a property of the Test object, is of type User, which has
    >> properties "name" and "password". Should the second entity be using
    >> properties "name" and "password" that reference a User object that
    >> links to the "user" property in the first entity block, or should they
    >> be written as they are, referencing the nested "user.name" and
    >> "user.password" properties of the Test object?
    >>
    >> And is it assumed that all properties are initialized in the
    >> constructor? E.g., with "map.key" above, which is a HashMap, if it is
    >> only valid after a "set" operation, I have to watch out for null
    >> values. If it can be assumed to be initialized, then it's not a
    >> problem.
    >>
    >> Thanks,
    >> Kevin
    >
    >
    > cheers,
    > --
    > shaun



    This archive was generated by hypermail 2.0.0 : Thu Dec 02 2004 - 13:13:45 EST