XML: unmarshalling heterogeneous collections

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

XML: unmarshalling heterogeneous collections

jtuchel
Hi there,

I am trying to define an XML to Object binding that not only allows to marshal a heterogeneous collection but also unmarshals it correctly.

I am currently using VW 7.4 and must admit I didn't check with 7.5.

My problem:
I have a list of folder objects that can contain folders as well as other objects. So every folder has to define a collection mapping for a list of unknown objects.

I have read about anyCollection on comp.lang.smalltalk, and it does marshal to xml quite nicely. It doesn't unmarshal though: all Collections are empty.

The same is also true for sequence_of containing an any-Mapping: The marshal'ed xml looks good but is not unmarshalled back to non-empty collections.

Does anybody know a way how to map heterogeneous collections so that both directions (objects->xml and xml->objects) work?

Any help is appreciated

thanx

Joachim

Reply | Threaded
Open this post in threaded view
|

AW: unmarshalling heterogeneous collections

Georg Heeg
Joachim,

Especially in the XML marshalling area, there are significant changes from
7.4 to 7.4.1 and furthermore to 7.5. We know this from our work interfacing
to SAP NetWeaver. Thus I recommend updating to 7.5 first.

Georg

Georg Heeg eK, Dortmund und Köthen, HR Dortmund A 12812
Tel. +49-3496-214328, Fax +49-3496-214712

> -----Ursprüngliche Nachricht-----
> Von: [hidden email] [mailto:[hidden email]]
> Gesendet: Donnerstag, 12. Juli 2007 13:51
> An: [hidden email]
> Betreff: XML: unmarshalling heterogeneous collections
>
> Hi there,
>
> I am trying to define an XML to Object binding that not only allows to
> marshal a heterogeneous collection but also unmarshals it correctly.
>
> I am currently using VW 7.4 and must admit I didn't check with 7.5.
>
> My problem:
> I have a list of folder objects that can contain folders as well as other
> objects. So every folder has to define a collection mapping for a list of
> unknown objects.
>
> I have read about anyCollection on comp.lang.smalltalk, and it does
> marshal to xml quite nicely. It doesn't unmarshal though: all Collections
> are empty.
>
> The same is also true for sequence_of containing an any-Mapping: The
> marshal'ed xml looks good but is not unmarshalled back to non-empty
> collections.
>
> Does anybody know a way how to map heterogeneous collections so that both
> directions (objects->xml and xml->objects) work?
>
> Any help is appreciated
>
> thanx
>
> Joachim


Reply | Threaded
Open this post in threaded view
|

Re: XML: unmarshalling heterogeneous collections

Eliot Miranda-2
In reply to this post by jtuchel
Have you checked-out SIXX?  SIXX isn't the most beautifully written piece of Smalltalk I've ever seen but it works and can be massaged...

On 7/12/07, [hidden email] <[hidden email]> wrote:
Hi there,

I am trying to define an XML to Object binding that not only allows to marshal a heterogeneous collection but also unmarshals it correctly.

I am currently using VW 7.4 and must admit I didn't check with 7.5.

My problem:
I have a list of folder objects that can contain folders as well as other objects. So every folder has to define a collection mapping for a list of unknown objects.

I have read about anyCollection on comp.lang.smalltalk, and it does marshal to xml quite nicely. It doesn't unmarshal though: all Collections are empty.

The same is also true for sequence_of containing an any-Mapping: The marshal'ed xml looks good but is not unmarshalled back to non-empty collections.

Does anybody know a way how to map heterogeneous collections so that both directions (objects->xml and xml->objects) work?

Any help is appreciated

thanx

Joachim


Reply | Threaded
Open this post in threaded view
|

RE: unmarshalling heterogeneous collections

Kogan, Tamara
In reply to this post by jtuchel


I hope the sample below helps.


schema := '<schemaBindings >
<xmlToSmalltalkBinding name="AnyCollection"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
targetNamespace="urn:point">
<object name="point" smalltalkClass="Point">
 <attribute name="x" ref="xsd:float"/>
 <attribute name="y" ref="xsd:float"/>
</object>
<object name="rectangle" smalltalkClass="Rectangle">
 <element name="origin" ref="point"/>
 <element name="corner" ref="point"/>
</object>
<object name="association" smalltalkClass="Association">
 <attribute name="key" ref="xsd:int"/>
 <attribute name="value" ref="xsd:string"/>
</object>
<object name = "CollectionHolder" smalltalkClass="ValueHolder">
<anyCollection name="value" setSelector="setValue:" xpath="child::*"/>
</object>
</xmlToSmalltalkBinding>
</schemaBindings >'.

manager := WebServices.XMLObjectMarshalingManager on:
                (WebServices.BindingBuilder loadFrom: schema
readStream).
value := ValueHolder new setValue: (OrderedCollection with: 1@1 with:
1->'1' ).
value value add: ( Rectangle origin: 0@0 corner: 20@20).
element := manager marshal: value atNamespace: 'urn:point'.

doc := XMLParser new validate: false; parse: element printString
readStream.
result := manager unmarshal: doc root.


Tamara Kogan
Smalltalk development,
Cincom Systems

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Thursday, July 12, 2007 7:51 AM
> To: [hidden email]
> Subject: XML: unmarshalling heterogeneous collections
>
> Hi there,
>
> I am trying to define an XML to Object binding that not only allows to
> marshal a heterogeneous collection but also unmarshals it correctly.
>
> I am currently using VW 7.4 and must admit I didn't check with 7.5.
>
> My problem:
> I have a list of folder objects that can contain folders as well as
other
> objects. So every folder has to define a collection mapping for a list
of
> unknown objects.
>
> I have read about anyCollection on comp.lang.smalltalk, and it does
> marshal to xml quite nicely. It doesn't unmarshal though: all
Collections
> are empty.
>
> The same is also true for sequence_of containing an any-Mapping: The
> marshal'ed xml looks good but is not unmarshalled back to non-empty
> collections.
>
> Does anybody know a way how to map heterogeneous collections so that
both
> directions (objects->xml and xml->objects) work?
>
> Any help is appreciated
>
> thanx
>
> Joachim

Reply | Threaded
Open this post in threaded view
|

RE: unmarshalling heterogeneous collections

Michael Gross-4
Hi,
    I was looking at this email and it looks like I am having a similar
problem.
I am calling a web service via a WSDL that should return a collection of
records. (A single record works fine)
The data is coming from the web service correctly and the xml document looks
good while I debugging but, I am getting an empty collection. Should
executing the following code change the way xml document is unmarshalled?  

Thanks !!

Mike Gross

Solution Center
Blue Heron Consulting
90 Airpark Dr, Suite 200
Rochester, NY 14624

www.BlueHeron-Consulting.com

Office: 800-253-3449 / 585-464-8035 (x207)
Fax:    800-464-9901 / 585-464-9760


-----Original Message-----
From: Kogan, Tamara [mailto:[hidden email]]
Sent: Friday, July 13, 2007 2:18 PM
To: [hidden email]; [hidden email]
Subject: RE: unmarshalling heterogeneous collections



I hope the sample below helps.


schema := '<schemaBindings >
<xmlToSmalltalkBinding name="AnyCollection"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
targetNamespace="urn:point">
<object name="point" smalltalkClass="Point">  <attribute name="x"
ref="xsd:float"/>  <attribute name="y" ref="xsd:float"/> </object> <object
name="rectangle" smalltalkClass="Rectangle">  <element name="origin"
ref="point"/>  <element name="corner" ref="point"/> </object> <object
name="association" smalltalkClass="Association">  <attribute name="key"
ref="xsd:int"/>  <attribute name="value" ref="xsd:string"/> </object>
<object name = "CollectionHolder" smalltalkClass="ValueHolder">
<anyCollection name="value" setSelector="setValue:" xpath="child::*"/>
</object> </xmlToSmalltalkBinding> </schemaBindings >'.

manager := WebServices.XMLObjectMarshalingManager on:
                (WebServices.BindingBuilder loadFrom: schema readStream).
value := ValueHolder new setValue: (OrderedCollection with: 1@1 with:
1->'1' ).
value value add: ( Rectangle origin: 0@0 corner: 20@20).
element := manager marshal: value atNamespace: 'urn:point'.

doc := XMLParser new validate: false; parse: element printString readStream.

result := manager unmarshal: doc root.


Tamara Kogan
Smalltalk development,
Cincom Systems

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Thursday, July 12, 2007 7:51 AM
> To: [hidden email]
> Subject: XML: unmarshalling heterogeneous collections
>
> Hi there,
>
> I am trying to define an XML to Object binding that not only allows to
> marshal a heterogeneous collection but also unmarshals it correctly.
>
> I am currently using VW 7.4 and must admit I didn't check with 7.5.
>
> My problem:
> I have a list of folder objects that can contain folders as well as
other
> objects. So every folder has to define a collection mapping for a list
of
> unknown objects.
>
> I have read about anyCollection on comp.lang.smalltalk, and it does
> marshal to xml quite nicely. It doesn't unmarshal though: all
Collections
> are empty.
>
> The same is also true for sequence_of containing an any-Mapping: The
> marshal'ed xml looks good but is not unmarshalled back to non-empty
> collections.
>
> Does anybody know a way how to map heterogeneous collections so that
both
> directions (objects->xml and xml->objects) work?
>
> Any help is appreciated
>
> thanx
>
> Joachim

Reply | Threaded
Open this post in threaded view
|

RE: unmarshalling heterogeneous collections

Kogan, Tamara
The code below doesn't represent a new way of unmarshaling. It's about
mapping collections where item type can be any type from the schema:
> <anyCollection name="value" setSelector="setValue:" xpath="child::*"/>

>     I was looking at this email and it looks like I am having a
similar
> problem.
> I am calling a web service via a WSDL that should return a collection
of
> records. (A single record works fine)
> The data is coming from the web service correctly and the xml document
> looks
> good while I debugging but, I am getting an empty collection. Should
> executing the following code change the way xml document is
unmarshalled?

It's hard to say that this is the same problem. If you create a test
case I can take a look.

Tamara


>
> Solution Center
> Blue Heron Consulting
> 90 Airpark Dr, Suite 200
> Rochester, NY 14624
>
> www.BlueHeron-Consulting.com
>
> Office: 800-253-3449 / 585-464-8035 (x207)
> Fax:    800-464-9901 / 585-464-9760
>
>
> -----Original Message-----
> From: Kogan, Tamara [mailto:[hidden email]]
> Sent: Friday, July 13, 2007 2:18 PM
> To: [hidden email]; [hidden email]
> Subject: RE: unmarshalling heterogeneous collections
>
>
>
> I hope the sample below helps.
>
>
> schema := '<schemaBindings >
> <xmlToSmalltalkBinding name="AnyCollection"
> xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
> targetNamespace="urn:point">
> <object name="point" smalltalkClass="Point">  <attribute name="x"
> ref="xsd:float"/>  <attribute name="y" ref="xsd:float"/> </object>
<object
> name="rectangle" smalltalkClass="Rectangle">  <element name="origin"
> ref="point"/>  <element name="corner" ref="point"/> </object> <object
> name="association" smalltalkClass="Association">  <attribute
name="key"
> ref="xsd:int"/>  <attribute name="value" ref="xsd:string"/> </object>
> <object name = "CollectionHolder" smalltalkClass="ValueHolder">
> <anyCollection name="value" setSelector="setValue:" xpath="child::*"/>
> </object> </xmlToSmalltalkBinding> </schemaBindings >'.
>
> manager := WebServices.XMLObjectMarshalingManager on:
> (WebServices.BindingBuilder loadFrom: schema
readStream).

> value := ValueHolder new setValue: (OrderedCollection with: 1@1 with:
> 1->'1' ).
> value value add: ( Rectangle origin: 0@0 corner: 20@20).
> element := manager marshal: value atNamespace: 'urn:point'.
>
> doc := XMLParser new validate: false; parse: element printString
> readStream.
>
> result := manager unmarshal: doc root.
>
>
> Tamara Kogan
> Smalltalk development,
> Cincom Systems
>
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]]
> > Sent: Thursday, July 12, 2007 7:51 AM
> > To: [hidden email]
> > Subject: XML: unmarshalling heterogeneous collections
> >
> > Hi there,
> >
> > I am trying to define an XML to Object binding that not only allows
to
> > marshal a heterogeneous collection but also unmarshals it correctly.
> >
> > I am currently using VW 7.4 and must admit I didn't check with 7.5.
> >
> > My problem:
> > I have a list of folder objects that can contain folders as well as
> other
> > objects. So every folder has to define a collection mapping for a
list

> of
> > unknown objects.
> >
> > I have read about anyCollection on comp.lang.smalltalk, and it does
> > marshal to xml quite nicely. It doesn't unmarshal though: all
> Collections
> > are empty.
> >
> > The same is also true for sequence_of containing an any-Mapping: The
> > marshal'ed xml looks good but is not unmarshalled back to non-empty
> > collections.
> >
> > Does anybody know a way how to map heterogeneous collections so that
> both
> > directions (objects->xml and xml->objects) work?
> >
> > Any help is appreciated
> >
> > thanx
> >
> > Joachim