• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[SOLVED]: WOXMLDecoder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SOLVED]: WOXMLDecoder


  • Subject: [SOLVED]: WOXMLDecoder
  • From: Baiss Eric Magnusson <email@hidden>
  • Date: Thu, 12 Aug 2004 15:54:21 -0700

With a very special thanks to Igor Clark for his persistent help, these are the key steps I used to implement XML input into the EO's of a WO app.

1) Generate a xml mapping model, such as:
<model>
<entity name="com.webobjects.foundation.NSMutableDictionary" xmlTag="Transaction_List" ignoreUnmappedTags="YES" contentsKey="transactionList"/>
<entity name="Transaction" xmlTag="transaction">
<property name="amount" xmlTag="amount"/>
...


2) In the wod file:

XMLfileOfTrans: WOFileUpload {
	data = dataForXMLdecoder;
	filePath = xmlFilePath;
	mimeType = aMimeType;
}

3) Start the mapping
NSData dataForXMLdecoder;
try {
java.net.URL mappingModelFile = application().resourceManager().pathURLForResourceNamed( "transactionMapping.xml", null, null );
WOXMLDecoder xmlDecoder = WOXMLDecoder.decoderWithMapping( mappingModelFile.toString() );
NSMutableDictionary dict = (NSMutableDictionary)xmlDecoder.decodeRootObject( dataForXMLdecoder );
NSMutableArray transactions = (NSMutableArray)dict.objectForKey( "transactionList" );


4) For those attributes that can't be directly mapped, like complex relationships, override <takeValueForKey> in the EOGenericRecord sub-classes. I stored the information in the sub-classes that I would need later, and then cleared that data out, by setting to <null> in <postProcess> the extra data, before inserting the object into the EOEditingContext.
After WOXMLDecoder has finished, (it seems to me that the parsing order is not a given)
for ( int i=0; i< transactions.count(); i++ ) {
t = (Transaction)transactions.objectAtIndex(i)
postProcess( t );
ec.insertObject( t );
...


----
Baiss Eric Magnusson
<http://www.Track-Your-Finances.com>
<http://www.CascadeWebDesign.com>
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: development vs deployment license
  • Next by Date: Re: development vs deployment license
  • Previous by thread: Re: Accessing WOAssociation in WOComponent with 5.2.3
  • Next by thread: web objects and interface builder working together
  • Index(es):
    • Date
    • Thread