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 <[email protected]> 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 <[email protected]>
> 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 <[email protected]>
>> 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 *[email protected] <[email protected]>*
> Mobile *+94719079739 <%2B94719079739>@*
>
>
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev