[vwnc] RE-Post Bug: WSDL Wizard/XML to Object tool code gen error

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 code gen error

toddk42
Just wondering if there was an official bug opened for the post below and/or if a fix will be in 7.7 (?)
Regards,
Todd King
-----------------------------------
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 King
tkkg42@...


Windows Liveā„¢: Keep your life in sync. Check it out.
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc