You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Daniel Kulp (JIRA)" <ji...@apache.org> on 2010/03/14 03:56:27 UTC

[jira] Commented: (CXF-2699) MapType does not set value to nillable

    [ https://issues.apache.org/jira/browse/CXF-2699?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845014#action_12845014 ] 

Daniel Kulp commented on CXF-2699:
----------------------------------


Well, I would argue that the schema is correct (it shouldn't be nillable), but the output XMl is wrong as the <value> element should not have been written at all.   It's minOccurs=0 so it doesn't need to be written out.

> MapType does not set value to nillable
> --------------------------------------
>
>                 Key: CXF-2699
>                 URL: https://issues.apache.org/jira/browse/CXF-2699
>             Project: CXF
>          Issue Type: Bug
>          Components: Aegis Databinding
>    Affects Versions: 2.2.6
>         Environment: windows xp, java 5
>            Reporter: alistair
>             Fix For: 2.2.7
>
>
> The MapType class (in org.apache.cxf.aegis.type.collection) creates the schema element for maps. It does not set nillable for the value in the entry.
> It is legal to have 
> HashMap<String, Object> myMap containing {myKey->null} and to return such a map from a call to a web method. 
> The following wsdl is generated : 
> ...
> <xsd:element name="myMap" nillable="true" type="string2anyTypeMap" /> 
> ...
> <xsd:complexType name="string2anyTypeMap"> 
> <xsd:sequence> 
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="entry"> 
> <xsd:complexType> 
> <xsd:sequence> 
> <xsd:element minOccurs="0" name="key" type="xsd:string" /> 
> <xsd:element minOccurs="0" name="value" type="xsd:anyType" /> 
> </xsd:sequence> 
> </xsd:complexType> 
> On a query that retrieves myMap I can get 
> ...
>    <entry>
>                            <key>myKey</key>
>                            <value ns6:nil="true" xmlns:ns6="http://www.w3.org/2001/XMLSchema-instance"/>
>    </ns1:entry>
> which does not conform to the generated schema.
> In type MapType createElement should probably be renamed to createKeyElement and a new createValueElement method that sets nillable to the result of type.isNillable().
> Current method:
>   /**
>      * Creates a element in a sequence for the key type and the value type.
>      */
>     private void createElement(XmlSchemaSequence seq, QName name, Type type) {
>         XmlSchemaElement element = new XmlSchemaElement();
>         seq.getItems().add(element);
>         element.setName(name.getLocalPart());
>         element.setSchemaTypeName(type.getSchemaType());
>         element.setMinOccurs(0);
>         element.setMaxOccurs(1);
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.