Hi All,

As an improvement to nullable support, the representation has been
implemented for xsi:nil as well and if the payload contains xsi:nil as an
attribute then the generated schema will include nullable="true" as shown
below

*Input:*

<h:person xsi:nil="true" xmlns:h="http://www.w3.org/TR/html4/"; xmlns:xsi="
http://www.w3.org/TR/html4/";>
<firstName xsi:nil="true">sample</firstName>
<phone primary="false" xsi:nil="true">0112655655<ext
xsi:nil="true">01</ext></phone>
<phone primary="false" xsi:nil="true">0112655655<ext
xsi:nil="true">01</ext></phone>
</h:person>

*Schema*:

{
  "$schema" : "http://json-schema.org/draft-04/schema#";,
  "nullable" : "true",
  "attributes" : {
    "xsi:nil" : {
      "nullable" : "false",
      "id" : "http://wso2jsonschema.org/xsi:nil";,
      "type" : "boolean"
    }
  },
  "id" : "http://wso2jsonschema.org";,
  "title" : "h:person",
  "type" : "object",
  "properties" : {
    "firstName" : {
      "nullable" : "true",
      "attributes" : {
        "xsi:nil" : {
          "nullable" : "false",
          "id" : "http://wso2jsonschema.org/xsi:nil";,
          "type" : "boolean"
        }
      },
      "id" : "http://wso2jsonschema.org/firstName";,
      "type" : "object",
      "value" : {
        "type" : "string"
      },
      "properties" : { }
    },
    "phone" : {
      "nullable" : "true",
      "id" : "http://wso2jsonschema.org/phone";,
      "type" : "array",
      "items" : [ {
        "attributes" : {
          "xsi:nil" : {
            "nullable" : "false",
            "id" : "http://wso2jsonschema.org/phone/0/xsi:nil";,
            "type" : "boolean"
          },
          "primary" : {
            "nullable" : "false",
            "id" : "http://wso2jsonschema.org/phone/0/primary";,
            "type" : "boolean"
          }
        },
        "id" : "http://wso2jsonschema.org/phone/0";,
        "type" : "object",
        "value" : {
          "type" : "number"
        },
        "properties" : {
          "ext" : {
            "nullable" : "true",
            "attributes" : {
              "xsi:nil" : {
                "nullable" : "false",
                "id" : "http://wso2jsonschema.org/phone/0/xsi:nil";,
                "type" : "boolean"
              }
            },
            "id" : "http://wso2jsonschema.org/phone/0/ext";,
            "type" : "object",
            "value" : {
              "type" : "number"
            },
            "properties" : { }
          }
        }
      } ]
    }
  },
  "namespaces" : [ {
    "prefix" : "xsi",
    "url" : "ssss"
  }, {
    "prefix" : "h",
    "url" : "http://www.w3.org/TR/html4/";
  } ]
}

Thanks,
Sohani


Sohani Weerasinghe
Senior Software Engineer
WSO2, Inc: http://wso2.com

Mobile  : +94 716439774
Blog     :http://christinetechtips.blogspot.com/
Twitter  : https://twitter.com/sohanichristine

On Tue, Jun 7, 2016 at 11:30 AM, Sohani Weerasinghe <soh...@wso2.com> wrote:

>
>
> Sohani Weerasinghe
> Senior Software Engineer
> WSO2, Inc: http://wso2.com
>
> Mobile  : +94 716439774
> Blog     :http://christinetechtips.blogspot.com/
> Twitter  : https://twitter.com/sohanichristine
>
> On Tue, Jun 7, 2016 at 10:45 AM, Malaka Silva <mal...@wso2.com> wrote:
>
>> Hi Sohani,
>>
>> I guess we are dealing with optional input/output here. So in that case
>> are we showing those in a different color or anyway to distinguish?
>>
> @Malaka: Yes, we are going to use a different icon for those nodes.
> eg: If it's an element, then the icon will be something created based on
> the previous icon used for the element, so that it will be displayed as an
> element with nullable
>
>>
>> On execution side this needs to be handled from data mapper mediator.
>>
>> On Tue, Jun 7, 2016 at 9:21 AM, Sohani Weerasinghe <soh...@wso2.com>
>> wrote:
>>
>>> Hi All,
>>>
>>> We are in a process of implementing the $subject and please find the
>>> implementation details.
>>>
>>> *Input*:
>>>
>>> <h:person xmlns:h="http://www.w3.org/TR/html4/";>
>>> <firstName>sample</firstName>
>>> <phone primary="false">0112655655<ext>01</ext></phone>
>>> <phone primary="false">0112655655<ext>01</ext></phone>
>>> </h:person>
>>>
>>> After loading the above payload, the generated schema will be as follows
>>>
>>> {
>>>   "$schema" : "http://json-schema.org/draft-04/schema#";,
>>>   *"nullable" : "false"*,
>>>   "id" : "http://wso2jsonschema.org";,
>>>   "title" : "h:person",
>>>   "type" : "object",
>>>   "properties" : {
>>>     "firstName" : {
>>>       *"nullable" : "false",*
>>>       "id" : "http://wso2jsonschema.org/firstName";,
>>>       "type" : "string"
>>>     },
>>>     *"nullable" : "false"*,
>>>     "phone" : {
>>>       "id" : "http://wso2jsonschema.org/phone";,
>>>       "type" : "array",
>>>       "items" : [ {
>>>         "attributes" : {
>>>           "primary" : {
>>>            * "nullable" : "false"*,
>>>             "id" : "http://wso2jsonschema.org/phone/0/primary";,
>>>             "type" : "boolean"
>>>           }
>>>         },
>>>         "id" : "http://wso2jsonschema.org/phone/0";,
>>>         "type" : "object",
>>>         "value" : {
>>>           "type" : "number"
>>>         },
>>>         "properties" : {
>>>           "ext" : {
>>>            * "nullable" : "false",*
>>>             "id" : "http://wso2jsonschema.org/phone/0/ext";,
>>>             "type" : "number"
>>>           }
>>>         }
>>>       } ]
>>>     }
>>>   },
>>>   "namespaces" : [ {
>>>     "prefix" : "h",
>>>     "url" : "http://www.w3.org/TR/html4/";
>>>   } ]
>>> }
>>>
>>> Then, user can right click on the node and click on 'Enable Nullable'
>>> and make the object or array or element, etc nullable.
>>>
>>>
>>> ​The schema will be as follows
>>>
>>> {
>>>   "$schema" : "http://json-schema.org/draft-04/schema#";,
>>>  * "nullable" : "true",*
>>>   "id" : "http://wso2jsonschema.org";,
>>>   "title" : "h:person",
>>>   "type" : "object",
>>>   "properties" : {
>>>     "firstName" : {
>>>       "nullable" : "false",
>>>       "id" : "http://wso2jsonschema.org/firstName";,
>>>       "type" : "string"
>>>     },
>>>     "nullable" : "false",
>>>     "phone" : {
>>>       "id" : "http://wso2jsonschema.org/phone";,
>>>       "type" : "array",
>>>       "items" : [ {
>>>         "attributes" : {
>>>           "primary" : {
>>>             "nullable" : "false",
>>>             "id" : "http://wso2jsonschema.org/phone/0/primary";,
>>>             "type" : "boolean"
>>>           }
>>>         },
>>>         "id" : "http://wso2jsonschema.org/phone/0";,
>>>         "type" : "object",
>>>         "value" : {
>>>           "type" : "number"
>>>         },
>>>         "properties" : {
>>>           "ext" : {
>>>             "nullable" : "false",
>>>             "id" : "http://wso2jsonschema.org/phone/0/ext";,
>>>             "type" : "number"
>>>           }
>>>         }
>>>       } ]
>>>     }
>>>   },
>>>   "namespaces" : [ {
>>>     "prefix" : "h",
>>>     "url" : "http://www.w3.org/TR/html4/";
>>>   } ]
>>> }
>>>
>>> If a user wants to disable it then, user can right click on the node and
>>> click on 'Disable Nullable'
>>>
>>>
>>> ​
>>> After enabling, we thought of changing the icon of the tree node so that
>>> user can easily identify whether a particular node is a nullable or not.
>>>
>>> Thanks,
>>> Sohani
>>> Sohani Weerasinghe
>>> Senior Software Engineer
>>> WSO2, Inc: http://wso2.com
>>>
>>> Mobile  : +94 716439774
>>> Blog     :http://christinetechtips.blogspot.com/
>>> Twitter  : https://twitter.com/hanichristine
>>>
>>> _______________________________________________
>>> Architecture mailing list
>>> architect...@wso2.org
>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>
>>>
>>
>>
>> --
>>
>> Best Regards,
>>
>> Malaka Silva
>> Senior Technical Lead
>> M: +94 777 219 791
>> Tel : 94 11 214 5345
>> Fax :94 11 2145300
>> Skype : malaka.sampath.silva
>> LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77
>> Blog : http://mrmalakasilva.blogspot.com/
>>
>> WSO2, Inc.
>> lean . enterprise . middleware
>> http://www.wso2.com/
>> http://www.wso2.com/about/team/malaka-silva/
>> <http://wso2.com/about/team/malaka-silva/>
>> https://store.wso2.com/store/
>>
>> Save a tree -Conserve nature & Save the world for your future. Print this
>> email only if it is absolutely necessary.
>>
>> _______________________________________________
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to