xmlToSmalltalkBinding heteregeneous collection, item class based on element content

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

xmlToSmalltalkBinding heteregeneous collection, item class based on element content

Ivo Roefs-2
Hi,

I'm trying to create an xmlToSmalltalkBinding to marshal/unmarshal following 2 xml elements.
(In the context of parsing Google API Contact feeds)

*** XML Element 1 ****
xml1 := '<feed>
<entry>
<category name="user"/>
<firstName>Ivo</firstName>
<lastName>Roefs</lastName>
</entry>
</feed>'
desiredObject := (Feed new)
entries: (User new firstName: 'Ivo'; lastName: 'Roefs'; yourself);
yourself

*** XML Element 2 ****
xml2 := '<feed>
<entry>
<category name="group"/>
<groupName>Smalltalkers</groupName>
</entry>
</feed>'
desiredObject := (Feed new)
entries: (Group new groupName: 'Smalltalkers'; yourself);
yourself
I started of with following binding description, but got stuck...
I can't figure out how to describe "entry" in the "feed" binding so that it refers to both User an Group. 
<schemaBindings>
<xmlToSmalltalkBinding targetNamespace="targetNamespace="urn:webservices"  defaultClassNamespace="MyCorp">
<object name="feed" smalltalkClass="Feed">
<element name="entry" aspect="entries" xpath="entry[category[@name='user']]"  maxOccurs="unbounded" minOccurs="0" ref="entry"/>
</object>
<object name="user" smalltalkClass="User">
<attribute name="firstName" ref="xsd:string"/>
<attribute name="lastName" ref="xsd:string"/>
</object>
<object name="group" smalltalkClass="Group">
<attribute name="groupName" ref="xsd:string"/>
</object>
</xmlToSmalltalkBinding>
</schemaBindings>

regards,
Ivo Roefs

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc