[vwnc] Re-Post Bug: WSDL Wizard/XML to Object tool generates

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

[vwnc] Re-Post Bug: WSDL Wizard/XML to Object tool generates

toddk42

(Some Xml did not transmit)

When a WSDL (and/or XSD) describes a complexType that contains an element with a "name" attribute with a value of "class", the tool will create an "x2oBinding" definition with the same element name and an "aspect" attribute with a value of "class". This translates into the generated class definition containing an an instance variable named "class" and corresponding selectors "#class" and "#class:"


For example, given the following XSD defintion:

{complexType name="SomeComplexType"}     {complexContent}         {sequence}             {element name="class" type="xsd:Boolean" minOccurs="0"/>}        {/sequence}    {/complexContent}{/complexType}
The corresponding x2oBinding definition will be:

{object name="SomeComplexType" smalltalkClass="SomeComplexType"} {element name="class" ref="ns:boolean" minOccurs="0" aspect="class"/}{/object}The end result will be an "SomeComplexType" class definition with a #class instance selector that returns the boolean instance variable, instead of the instance's Class.

My own personal fix to this problem was to modify the XMLObjectBindingPolicy>>addAspectAttributeTo: method to call a new #makeSafeAttribute: method that guards against creating an aspect named "class":
addAspectAttributeTo: anXMLElement | attr value |
(attr := anXMLElement attributeNamed: 'name' ifAbsent: [ nil]) == nil ifTrue: [ (attr := anXMLElement attributeNamed: 'tag' ifAbsent: [ nil]) == nil ifTrue: [ attr := anXMLElement attributeNamed: 'ref' ifAbsent: [ nil]]]. attr == nil ifTrue: [ ^self error: (#CanNotSetAspect << #webservices>> 'Can not set aspect')]. value := attr value.
(value detect: [ :c | c = $:] ifNone: [ nil ]) ~~ nil ifTrue: [value := value copyFrom: ( value indexOf: $: ) + 1 to: value size].
self elementAssist addAttribute: 'aspect' value: (self makeSafeAspectAttribute: ( self createAspectValue: value )) to: anXMLElement.

makeSafeAspectAttribute: aSymbol
(aSymbol = #class) ifTrue: [^#apiClass] ifFalse: [^aSymbol]

A nicer solution would allow for the user to specify what they want the new name to be.

Kind regards,Todd [hidden email]

_________________________________________________________________
HotmailĀ® has a new way to see what's up with your friends.
http://windowslive.com/Tutorial/Hotmail/WhatsNew?ocid=TXT_TAGLM_WL_HM_Tutorial_WhatsNew1_052009
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc