[vwnc] Bug: WSDL Wizard/XML to Object tool generates Object>>#class overrides when a

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

[vwnc] Bug: WSDL Wizard/XML to Object tool generates Object>>#class overrides when a

toddk42

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:
                                                                     

The corresponding x2oBinding definition will be:
               

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]


_________________________________________________________________
Insert movie times and more without leaving HotmailĀ®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd1_052009
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc