Hi All, As per the offline discussion we had, shall we proceed with the following approach?
1. All namespaces used in the schema should be listed with preferred prefix value in the root level of the schema under "namespaces" field as an JSON Array *"namespaces":[{ "prefix":"ns1", "url":"http://employee.lastname <http://employee.lastname/>"},{"prefix":"ns2", "url":"http://namespace.test <http://namespace.test/>"}]* 2. Instead of using the "xmlns" field, use the prefix in each element as shown below "*ns1*:firstname":{ "id":"http://jsonschema.net/employee/0/firstname", "type":"string" }" Additionally, when generating the tree view we can validate if the added prefix is available in the "namespaces" field. Please find the updated schema with namespaces { "$schema":"http://json-schema.org/draft-04/schema#", "id":"http://jsonschema.net", "title":"*ns1*:employees", "type":"object", "properties":{ "*ns1*:employee":{ "id":"http://jsonschema.net/employee", "type":"array", "items":[ { "id":"http://jsonschema.net/employee/0", "type":"object", "properties":{ "*ns1*:firstname":{ "id":"http://jsonschema.net/employee/0/firstname", "type":"string" }, "*ns2*:lastname":{ "id":"http://jsonschema.net/employee/0/lastname", "type":"string" } }, "required":[ "firstname", "lastname" ] } ], "required":[ "arrayRequired" ] } }, "required":[ "employees" ], *"namespaces":[{ "prefix":"ns1", "url":"http://employee.lastname <http://employee.lastname/>"},{"prefix":"ns2", "url":"http://namespace.test <http://namespace.test/>"}]* } 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, Mar 21, 2016 at 1:53 PM, Nuwan Pallewela <nuw...@wso2.com> wrote: > Hi All, > > We have discussed to go as the following to represent name-spaces in data > mapper JSON schema's. > > > - Each element can represent with a name-space value by using* "xmlns" > *field and url value as a JSON string. > - "firstname":{ > "id":" > http://jsonschema.net/employee/0/firstname", > "type":"string", > "xmlns":"http://namespace.test" > }" > - And all name-spaces used in the schema should be listed with > preferred prefix value in the root level of the schema under > *"namespace"* field as a JSON Array of namespace JSON objects. > - Eg: "namespaces": [ { "prefix":"ns1", "url":" > http://employee.lastname"} , {"prefix":"ns2", "url":" > http://namespace.test"} ] > - Name-space JSON object should contain two fields as* "prefix" *and *"url" > *with JSON String values. > - { "prefix":"ns1", "url":"http://employee.lastname"} > > Following schema shows a sample JSON schema for data mapper with > name-spaces. > { > "$schema":"http://json-schema.org/draft-04/schema#", > "id":"http://jsonschema.net", > "title":"employees", > "type":"object", > *"xmlns":"http://namespace.test <http://namespace.test>",* > "properties":{ > "employee":{ > "id":"http://jsonschema.net/employee", > "type":"array", > *"xmlns":"http://namespace.test <http://namespace.test>",* > "items":[ > { > "id":"http://jsonschema.net/employee/0", > "type":"object", > "properties":{ > "firstname":{ > "id":"http://jsonschema.net/employee/0/firstname", > "type":"string", > *"xmlns":"http://namespace.test > <http://namespace.test>"* > }, > "lastname":{ > "id":"http://jsonschema.net/employee/0/lastname", > "type":"string", > *"xmlns":"http://employee.lastname > <http://employee.lastname>"* > } > }, > "required":[ > "firstname", > "lastname" > ] > } > ], > "required":[ > "arrayRequired" > ] > } > }, > "required":[ > "employees" > ], > *"namespaces":[{ "prefix":"ns1", "url":"http://employee.lastname > <http://employee.lastname>"},{"prefix":"ns2", "url":"http://namespace.test > <http://namespace.test>"}]* > } > > Thanks, > Nuwan > > > On Fri, Mar 18, 2016 at 3:52 PM, Maheeka Jayasuriya <mahe...@wso2.com> > wrote: > >> Hi Sohani, >> >> Instead of properties array with attributes supported with @ prefix, can >> we use an attributes array in the schema ? >> >> For example : >> >> Current definition : >> >> "address": { >> "id": "http://jsonschema.net/employee/0/address", >> "type": "object", >> "properties": { >> "city": { >> "id": "http://jsonschema.net/employee/0/address/city", >> "type": "string" >> }, >> "@no": { >> "id": "http://jsonschema.net/employee/0/address/no", >> "type": "string" >> }, >> "road": { >> "id": "http://jsonschema.net/employee/0/address/road", >> "type": "string" >> } >> } >> } >> >> With attributes array : >> >> "address": { >> "id": "http://jsonschema.net/employee/0/address", >> "type": "object", >> "attributes": { >> "no": { >> "id": "http://jsonschema.net/employee/0/address/no", >> "type": "string" >> } >> }, >> "properties": { >> "city": { >> "id": "http://jsonschema.net/employee/0/address/city", >> "type": "string" >> }, >> "road": { >> "id": "http://jsonschema.net/employee/0/address/road", >> "type": "string" >> } >> } >> } >> >> Two reasons to suggest this : >> >> 1. We do not have to use a prefix to define attributes and they can be >> easily distinguished from other fields since they are defined separate from >> other fields (properties) >> 2. In the case of a primitive type with attributes, we can still preserve >> the type as string and have attributes instead of using properties (since >> properties are only valid in json schema for object type) >> >> >> WDYT? >> >> Thanks, >> Maheeka >> >> Maheeka Jayasuriya >> Software Engineer >> Mobile : +94777750661 >> >> On Wed, Mar 16, 2016 at 10:54 AM, Sohani Weerasinghe <soh...@wso2.com> >> wrote: >> >>> Hi, >>> >>> Please find the schema and the visual representation for representing >>> the attributes. >>> >>> { >>> "$schema": "http://json-schema.org/draft-04/schema#", >>> "id": "http://jsonschema.net", >>> "title" : "employees", >>> "type": "object", >>> "properties": { >>> "employee": { >>> "id": "http://jsonschema.net/employee", >>> "type": "array", >>> "items": { >>> "id": "http://jsonschema.net/employee/0", >>> "type": "object", >>> "properties": { >>> "firstname": { >>> "id": "http://jsonschema.net/employee/0/firstname", >>> "type": "string" >>> }, >>> "lastname": { >>> "id": "http://jsonschema.net/employee/0/lastname", >>> "type": "string" >>> }, >>> "address": { >>> "id": "http://jsonschema.net/employee/0/address", >>> "type": "object", >>> "properties": { >>> "city": { >>> "id": "http://jsonschema.net/employee/0/address/city", >>> "type": "string" >>> }, >>> * "@no": {* >>> "id": "http://jsonschema.net/employee/0/address/no", >>> "type": "string" >>> }, >>> "road": { >>> "id": "http://jsonschema.net/employee/0/address/road", >>> "type": "string" >>> } >>> } >>> } >>> }, >>> "required": [ >>> "firstname", >>> "lastname", >>> "address" >>> ] >>> }, >>> "required": [ >>> "0" >>> ] >>> } >>> }, >>> "required": [ >>> "employee" >>> ] >>> } >>> >>> 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 Wed, Mar 16, 2016 at 10:35 AM, Sohani Weerasinghe <soh...@wso2.com> >>> wrote: >>> >>>> Thanks Nuwan. Shall we go with '@' then? >>>> >>>> Sohani Weerasinghe >>>> Software Engineer >>>> WSO2, Inc: http://wso2.com >>>> >>>> Mobile : +94 716439774 >>>> Blog :http://christinetechtips.blogspot.com/ >>>> Twitter : https://twitter.com/sohanichristine >>>> >>>> On Wed, Mar 16, 2016 at 10:23 AM, Nuwan Pallewela <nuw...@wso2.com> >>>> wrote: >>>> >>>>> Hi sohani, >>>>> >>>>> I think we do not need to include new type called "attr" to define it >>>>> as a attribute. We can name the field with a prefix like "@" or "attr_". >>>>> >>>>> Eg: >>>>> "@firstname": { >>>>> "id": "http://jsonschema.net/employee/0/firstname", >>>>> "type": "string" >>>>> }, >>>>> >>>>> or >>>>> >>>>> "attr_firstname": { >>>>> "id": "http://jsonschema.net/employee/0/firstname", >>>>> "type": "string" >>>>> }, >>>>> >>>>> Thanks, >>>>> Nuwan >>>>> >>>>> On Wed, Mar 16, 2016 at 10:15 AM, Sohani Weerasinghe <soh...@wso2.com> >>>>> wrote: >>>>> >>>>>> Hi Nuwan/ Viraj, >>>>>> >>>>>> Can you please mention how are we going to handle $subject? >>>>>> >>>>>> Can we have a new field as attr as below to handle the attributes? >>>>>> >>>>>> "firstname": { >>>>>> "id": "http://jsonschema.net/employee/0/firstname", >>>>>> "type": "string", >>>>>> *"attr" : "xyz"* >>>>>> }, >>>>>> >>>>>> 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 >>> >>> >> > > > -- > ---------------------------------------------------------- > > *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