Hi All,

As per the offline discussion we had, xsi:type can be supported in the JSON
schema as described below

<address postalcode="111" *xsi:type="ipo:UKAddress"*>123
<city>ABC</city>
</address>

xsi:type can be added to a newly introduced json array called
"elementIdentifiers" and the value will be appended to to the field name in
the schema as shown below

{
"$schema": "http://json-schema.org/draft-04/schema#";,
"title": "person",
"id": "http://wso2jsonschema.org";,
"type": "object",
"properties": {
"firstName": {
"id": "http://wso2jsonschema.org/firstName";,
"type": "string"
},
"*address,xsi:type=ipo:UKAddress"*: {
                                         "id": "
http://wso2jsonschema.org/phone";,
"type": "object",
"value":{
"type": "number"
},

"properties": {
"city": {
"id": "http://wso2jsonschema.org/address/city";,
"type": "string"
}
},
"attributes": {
"postalcode": {
"id": "http://wso2jsonschema.org/address/postalcode";,
"type": "string"
}
}
}
},
*"elementIdentifiers": [{*
* "type": "xsi:type"*
* }]*
}

@Nuwan : Feel free to add things we've discussed if I've missed anything

Thanks,
Sohani


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

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

On Mon, Apr 11, 2016 at 11:57 AM, Sohani Weerasinghe <soh...@wso2.com>
wrote:

> Correction : This shouldn't add for the root level.
>
> Sohani Weerasinghe
> Software Engineer
> WSO2, Inc: http://wso2.com
>
> Mobile  : +94 716439774
> Blog     :http://christinetechtips.blogspot.com/
> Twitter  : https://twitter.com/sohanichristine
>
> On Mon, Apr 11, 2016 at 11:32 AM, Sohani Weerasinghe <soh...@wso2.com>
> wrote:
>
>> Thanks Viraj.
>>
>> I think this should be applied to the root level as well.
>>
>> {
>> "$schema": "http://json-schema.org/draft-04/schema#";,
>> "title": "person",
>>        * "value"{*
>> *             "id": "http://wso2jsonschema.org
>> <http://wso2jsonschema.org>",*
>> *     "type": "object*
>> *            },*
>> "properties": {
>> "firstName": {
>> "id": "http://wso2jsonschema.org/firstName";,
>> "type": "string"
>> },
>> "phone": {
>> "id": "http://wso2jsonschema.org/phone";,
>> "type": "array",
>> "items": [{
>>                                 *  “value”:{*
>> *                                           "id":
>> "http://wso2jsonschema.org/phone/phone
>> <http://wso2jsonschema.org/phone/phone>",*
>> *           "type": "number"*
>> *                                    },*
>> "attributes": {
>> "primary": {
>> "id": "http://wso2jsonschema.org/phone/primary";,
>> "type": "boolean"
>> }
>> }
>> }]
>> }
>> }
>> }
>>
>>
>>
>>
>>
>>
>>
>> Sohani Weerasinghe
>> Software Engineer
>> WSO2, Inc: http://wso2.com
>>
>> Mobile  : +94 716439774
>> Blog     :http://christinetechtips.blogspot.com/
>> Twitter  : https://twitter.com/sohanichristine
>>
>> On Mon, Apr 11, 2016 at 11:14 AM, Sohani Weerasinghe <soh...@wso2.com>
>> wrote:
>>
>>> Ok.  For an xml like below, let's have the value field as follows
>>>
>>> <person>
>>>
>>>        <firstName>xyz</firstName>
>>>
>>>        <phone primary="true">071655339</phone>
>>>
>>>        <phone primary="false">0112655333</phone> </person>
>>> </person>
>>>
>>> {
>>>
>>> "$schema": "http://json-schema.org/draft-04/schema#";,
>>>
>>> "title": "person",
>>>
>>> "id": "http://wso2jsonschema.org";,
>>>
>>> "type": "object",
>>>
>>> "properties": {
>>>
>>> "firstName": {
>>>
>>> "id": "http://wso2jsonschema.org/firstName";,
>>>
>>> "type": "string"
>>>
>>> },
>>>
>>> "phone": {
>>>
>>> "id": "http://wso2jsonschema.org/phone";,
>>>
>>> "type": "array",
>>>
>>> "items": [{
>>>
>>> * “value”:{*
>>>
>>> * "id": "http://wso2jsonschema.org/phone/phone
>>> <http://wso2jsonschema.org/phone/phone>",*
>>>
>>> * "type": "number"*
>>>
>>> * },*
>>>
>>> "attributes": {
>>>
>>> "primary": {
>>>
>>> "id": "http://wso2jsonschema.org/phone/primary";,
>>>
>>> "type": "boolean"
>>>
>>> }
>>>
>>> }
>>>
>>> }]
>>>
>>> }
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> Sohani Weerasinghe
>>> Software Engineer
>>> WSO2, Inc: http://wso2.com
>>>
>>> Mobile  : +94 716439774
>>> Blog     :http://christinetechtips.blogspot.com/
>>> Twitter  : https://twitter.com/sohanichristine
>>>
>>> On Mon, Apr 11, 2016 at 11:05 AM, Nuwan Pallewela <nuw...@wso2.com>
>>> wrote:
>>>
>>>> Hi Sohani,
>>>>
>>>> +1 for the above approaches.
>>>>
>>>> We have to decide on how to represent non identical elements with same
>>>> name. Viraj is working on it.
>>>>
>>>> Thanks,
>>>> Nuwan
>>>>
>>>> On Mon, Apr 11, 2016 at 10:44 AM, Sohani Weerasinghe <soh...@wso2.com>
>>>> wrote:
>>>>
>>>>> Hi Viraj/Nuwan,
>>>>>
>>>>> Really appreciate your input on this
>>>>>
>>>>> Thanks,
>>>>> Sohani
>>>>>
>>>>> Sohani Weerasinghe
>>>>> Software Engineer
>>>>> WSO2, Inc: http://wso2.com
>>>>>
>>>>> Mobile  : +94 716439774
>>>>> Blog     :http://christinetechtips.blogspot.com/
>>>>> Twitter  : https://twitter.com/sohanichristine
>>>>>
>>>>> On Tue, Apr 5, 2016 at 12:06 PM, Sohani Weerasinghe <soh...@wso2.com>
>>>>> wrote:
>>>>>
>>>>>> Hi All,
>>>>>>
>>>>>> This is regarding clarifying the $subject.
>>>>>>
>>>>>> If we consider an xml as below, we are currently generating the below
>>>>>> json schema
>>>>>>
>>>>>> <h:person xmlns:h="http://www.w3.org/TR/html4/";>
>>>>>> <firstName>susinda</firstName>
>>>>>>         <phone primary="true">0717777771<ext>01</ext></phone>
>>>>>> <phone primary="false">0112655655<ext>01</ext></phone>
>>>>>> </h:person>
>>>>>>
>>>>>>
>>>>>> {
>>>>>> "$schema": "http://json-schema.org/draft-04/schema#";,
>>>>>> "title": "h:person",
>>>>>> "id": "http://wso2jsonschema.org";,
>>>>>> "type": "object",
>>>>>> "properties": {
>>>>>> "firstName": {
>>>>>> "id": "http://wso2jsonschema.org/firstName";,
>>>>>> "type": "string"
>>>>>> },
>>>>>> "phone": {
>>>>>> "id": "http://wso2jsonschema.org/phone";,
>>>>>> "type": "array",
>>>>>> "items": [{
>>>>>> "id": "http://wso2jsonschema.org/phone/0";,
>>>>>> "type": "object",
>>>>>> "properties": {
>>>>>> "ext": {
>>>>>> "id": "http://wso2jsonschema.org/phone/0/ext";,
>>>>>> "type": "number"
>>>>>> }
>>>>>> },
>>>>>> "attributes": {
>>>>>> "primary": {
>>>>>> "id": "http://wso2jsonschema.org/phone/0/primary";,
>>>>>> "type": "boolean"
>>>>>> }
>>>>>> }
>>>>>> }]
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> But the issue is, we don't have any field to define the data type for
>>>>>> phone ( eg: number). So are we going to introduce a new field as below to
>>>>>> define the type?
>>>>>>
>>>>>> "phone": {
>>>>>> "id": "http://wso2jsonschema.org/phone";,
>>>>>> "type": "array",
>>>>>> "items": [{
>>>>>> "id": "http://wso2jsonschema.org/phone/0";,
>>>>>> "type": "object",
>>>>>>                                 "value":{
>>>>>>                                       type: "number",
>>>>>>                                       ....
>>>>>>
>>>>>>                                   } ,
>>>>>> "properties": {
>>>>>> "ext": {
>>>>>> "id": "http://wso2jsonschema.org/phone/0/ext";,
>>>>>> "type": "number"
>>>>>> }
>>>>>> },
>>>>>> "attributes": {
>>>>>> "primary": {
>>>>>> "id": "http://wso2jsonschema.org/phone/0/primary";,
>>>>>> "type": "boolean"
>>>>>> }
>>>>>> }
>>>>>> }]
>>>>>> }
>>>>>>
>>>>>> Please advice.
>>>>>>
>>>>>> Also, how are we going to represent an array which contains non
>>>>>> identical elements. Are we going to introduce xsi:type?
>>>>>>
>>>>>> Really appreciate your input in proceeding with this.
>>>>>>
>>>>>> Thanks,
>>>>>> Sohani
>>>>>>
>>>>>> Sohani Weerasinghe
>>>>>> Software Engineer
>>>>>> WSO2, Inc: http://wso2.com
>>>>>>
>>>>>> Mobile  : +94 716439774
>>>>>> Blog     :http://christinetechtips.blogspot.com/
>>>>>> Twitter  : https://twitter.com/sohanichristine
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> ----------------------------------------------------------
>>>>
>>>> *Nuwan Chamara Pallewela*
>>>>
>>>>
>>>> *Software Engineer*
>>>>
>>>> *WSO2, Inc. *http://wso2.com
>>>> *lean . enterprise . middleware*
>>>>
>>>> Email   *nuw...@wso2.com <nuw...@wso2.com>*
>>>> Mobile  *+94719079739 <%2B94719079739>@*
>>>>
>>>>
>>>>
>>>
>>
>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to