gowsdl icon indicating copy to clipboard operation
gowsdl copied to clipboard

Can't evaluate field Restriction in type *gowsdl.XSDAttribute

Open tmlbl opened this issue 7 years ago • 8 comments

Getting the following error on Windows and Linux:

genTypes error template: types:28:55: 
executing "Attributes" at <.Restriction.Base>: 
can't evaluate field Restriction in type *gowsdl.XSDAttribute

To reproduce run:

 gowsdl https://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl

tmlbl avatar Aug 22 '17 05:08 tmlbl

Part of the problem with the ONVIF specification is that gowsdl does not form the correct URL to fetch one of the includes, getting a 404, and no error is reported. I will submit a PR for that issue but the above error still persists.

tmlbl avatar Aug 22 '17 17:08 tmlbl

Here is an example of one of the types which is not being handled and causing the template error.

It seems that this should result in []int32 but since it does not have a restriction like gowsdl is expecting, it ends up with a nil pointer for .Restriction

<xs:simpleType name="EAPMethodTypes">
	<xs:list itemType="xs:int"/>
</xs:simpleType>

tmlbl avatar Aug 22 '17 17:08 tmlbl

I have the same problem, when gowsdl is trying to parse such xsd:

<xsd:attribute name="CC_IssuingCountryInd">
    <xsd:annotation>
        <xsd:documentation>Country where the Credit Card was issued.</xsd:documentation>
    </xsd:annotation>
</xsd:attribute>

There is no Restriction element...

🍀  genTypes error template: types:27:54: 
executing "Attributes" at <.SimpleType.Restrict...>: 
can't evaluate field Restriction in type *gowsdl.XSDSimpleType

smgladkovskiy avatar Sep 27 '17 07:09 smgladkovskiy

gowsdl can't handle a reference to attribute definition:

	<xs:attribute ref="xmime:contentType" use="optional"/>

@smgladkovskiy default type of xsd:attribute is anyType. Should it be interface{} or string?

realmfoo avatar Sep 27 '17 15:09 realmfoo

@realmfoo take a look at this definition of attribute that I faced with:

<xsd:attribute name="AiportCode" use="optional">
    <xsd:annotation>
        <xsd:documentation>Airport city code.</xsd:documentation>
    </xsd:annotation>
    <xsd:simpleType>
        <xsd:restriction base="AirportCitySimpleType"/>
    </xsd:simpleType>
</xsd:attribute>

I think that it would be better if it would be an interface{}. What do you think?

smgladkovskiy avatar Sep 27 '17 17:09 smgladkovskiy

I can share xsd with such cases to test on. :)

smgladkovskiy avatar Sep 27 '17 17:09 smgladkovskiy

In my case, as i understand, gowsdl is trying to parse restriction for simpleType when it is no restriction element.

smgladkovskiy avatar Sep 27 '17 17:09 smgladkovskiy

I'm a having a similar issue, except it seems the problem really is with simpleType restriction:

genTypes error template: types:30:54: executing "Attributes" at <.SimpleType.Restrict...>: can't evaluate field Restriction in type *gowsdl.XSDSimpleType

given this chunk from the .xsd file:

	<simpleType name="status.type">
		<restriction base="NMTOKEN">
			<enumeration value="Reset"/>
			<enumeration value="Continue"/>
		</restriction>
	</simpleType>
	<simpleType name="messageStatus.type">
		<restriction base="NMTOKEN">
			<enumeration value="UnAuthorized"/>
			<enumeration value="NotRecognized"/>
			<enumeration value="Received"/>
			<enumeration value="Processed"/>
			<enumeration value="Forwarded"/>
		</restriction>
	</simpleType>
	<simpleType name="non-empty-string">
		<restriction base="string">
			<minLength value="1"/>
		</restriction>
	</simpleType>
	<simpleType name="severity.type">
		<restriction base="NMTOKEN">
			<enumeration value="Warning"/>
			<enumeration value="Error"/>
		</restriction>
	</simpleType>
	<!-- COMMON ATTRIBUTES and ATTRIBUTE GROUPS -->
	<attribute name="id" type="ID"/>
	<attribute name="version" type="tns:non-empty-string"/>
	<attributeGroup name="headerExtension.grp">
		<attribute ref="tns:id"/>
		<attribute ref="tns:version" use="required"/>
		<anyAttribute namespace="##other" processContents="lax"/>
		<!--attribute ref="soap:mustUnderstand" use="optional"/-->
	</attributeGroup>
	<attributeGroup name="bodyExtension.grp">
		<attribute ref="tns:id"/>
		<attribute ref="tns:version" use="required"/>
		<anyAttribute namespace="##other" processContents="lax"/>
	</attributeGroup>

jbowles avatar Sep 30 '17 11:09 jbowles