sorry, still use a map so that you only get the bits you want, but don't try and force xmlcoder to give you the structure you want. use xslt for that.

Simon


On 31 Dec 2008, at 10:03, Kamal D Shah wrote:

Thanks Simon.

I tried that. I ran into one problem though. The 'no-mapping' XML produced by WOXMLCoder has a peculiar way of including the entire object graph in the first few elements and then having references to the ids later. This is not allowing me to do what I want even with XSLT.

For example, if I want the XML for all employees, the XML for the first employee will have its department's XML too. Now the department's XML will have all employees in that department. When the next employee in the array is to be displayed, it does not come up as the full XML but only a reference to the earlier instance of the employee. I was unable to figure out how to handle this with XSLT.

Any ideas on how to avoid this?

Thanks
Kamal



On 30-Dec-08, at 10:28 PM, Simon McLean wrote:


trying to get xmlcoder to give you what you are looking for is like trying to get blood out of a stone. by introducing a pojo to represent the <depts> tag you will be able to bodge it, but it's much more straight forward to just take the raw un-bodged output and stick it through an XSLT stylesheet.

Simon


On 30 Dec 2008, at 12:26, Kamal D Shah wrote:

Hi all,

I have an array of objects that I want to encode to XML. Let's say an array of departments. I need the XML to be generated to look like:

<depts>
<dept>
    <name>B</name>
    <description>BBBB</description>
</dept>
<dept>
    <name>A</name>
    <description>AAAA</description>
</dept>
</depts>
I am unable to get the <depts> and </depts> tags. I get only the inner XML.

I use a mapping file that looks like:

<model>
        <entity name="com.webobjects.foundation.NSArray" xmlTag="depts">
<property name="com.webobjects.eocontrol.EOGenericRecord" xmlTag="dept"/>
        </entity>
        
<entity name="com.webobjects.eocontrol.EOGenericRecord" xmlTag="dept">
                <property name="name" xmlTag="name"/>
                <property name="description" xmlTag="description"/>
        </entity>
</model>

In my code, I have the following:

WOXMLCoder coder = WOXMLCoder.coderWithMapping(mapFilePath);

String responseXML = coder.encodeRootObjectForKey(depts, "depts");
where depts is an NSArray with the department objects (EOGenericRecords). What mistake could I be making?
Thanks a ton in advance...
Kamal



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/simon_mclean%40mac.com

This email sent to simon_mcl...@mac.com




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kamal%40thinkgrene.com

This email sent to ka...@thinkgrene.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/simon_mclean%40mac.com

This email sent to simon_mcl...@mac.com




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to