Re: [Dev] Issue in representing an array which contains non identical elements

2016-03-23 Thread Sohani Weerasinghe
Hi All,

If we consider the generated json schema is a valid one, then when
generating the tree from that schema we have to treat "urn:sObjects" as two
arrays. i.e before creating the tree nodes we have to iterate through the
items section and then check for the objects inside that and then create
two tree nodes ( two arrays) containing the elements.

- urn:sObjects (array)
 - AccountId
 - FirstName
 - LastName

- urn:sObjects (array)
 - Name

When we are saving the editor we read the tree and then serialize the
values to a file. In that case, we treat these nodes and two arrays. As a
result the created json schema will be different that the initial schema.

How are we going to handle this situation?

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 23, 2016 at 9:55 PM, Susinda Perera  wrote:

> Online xsd generators[1] generate xsd as one object having all four
> elements as child elements of urn:sObjects, without considering xsi:type.
> https://devutilsonline.com/xsd-xml/generate-xsd-from-xml
>
> On Wed, Mar 23, 2016 at 9:47 PM, Susinda Perera  wrote:
>
>>
>>
>> On Wed, Mar 23, 2016 at 7:51 PM, Awanthika Senarath 
>> wrote:
>>
>>> Even though these arrays are identical, AFAIS they may occur independent,
>>>
>>> as in we may have 5 of the first array with the three items and 3 of the
>>> other array which is completely unrelated to the first array,
>>>
>>>
>>> In that case is it okey to represent them as a single array?
>>>
>>> according to [1] it seems like the xsi:type attribute is not just any
>>> attribute but something similar to a key word in XML. in that case IMO it
>>> is not correct to represent these two arrays as a merged array instance.
>>>
>> The xsi:type attribute is used to identify derived complex types[1]. In
>> this example we have 2  objects which have different
>> xsi:types. (i.e one does not have a xsi:type but other one
>> having xsi:type="urn1:Contact") Therefore these two are different
>> objects even though it has same name.
>> However by looking at the given xml we can not say that it's xsd would
>> have  array or single element because in this example we
>> have only one object from each. Shall we add and object of 
>> and check?
>>
>> [1] -
>> http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.xmleditor.doc.user%2Ftopics%2Ftxsityp.html
>>
>>
>>>
>>> We need to consider xsi:type attribute as a keyword. I dont know how
>>> viable this is though.
>>>
>>>
>>>
>>>
>>>
>>> [1]
>>> http://stackoverflow.com/questions/21216778/how-to-define-xsitype-as-an-attribute-in-xml-schema
>>>
>>> Regards
>>> Awanthika
>>>
>>>
>>>
>>> Awanthika Senarath
>>> Software Engineer, WSO2 Inc.
>>> Mobile: +94717681791
>>>
>>>
>>>
>>> On Wed, Mar 23, 2016 at 7:17 PM, Sohani Weerasinghe 
>>> wrote:
>>>
 Hi All,

 If we consider the below xml, "urn:sObjects" is an array which contains
 elements which are not identical.

 First array contains AccountId, FirstName, LastName and the other array
 contains Name.

  >>> xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"  xmlns:xsi="
 http://www.w3.org/2001/XMLSchema-instance";>
  

001D00HRzKD
Jane
Doe
 
 
Acme Rockets, Inc.
 
  

 The generated json schema would be as follows

 {
"$Schema":"http://json-schema.org/draft-04/schema#";,
"title":"urn:create",
"id":"http://jsonschema.net";,
"type":"object",
"properties":{
   "urn:create":{
  "id":"http://jsonschema.net/urn:create";,
  "type":"object",
  "properties":{
 "urn:sObjects":{
"id":"http://jsonschema.net/urn:create/urn:sObjects";,
"type":"array",
"items":[
   {
  "id":"
 http://jsonschema.net/urn:create/urn:sObjects/0";,
  "type":"object",
  "properties":{
 "AccountId":{
"id":"
 http://jsonschema.net/urn:create/urn:sObjects/0/AccountId";,
"type":"string"
 },
 "@type":{
"id":"
 http://jsonschema.net/urn:create/urn:sObjects/0/@type";,
"type":"string"
 },
 "FirstName":{
"id":"
 http://jsonschema.net/urn:create/urn:sObjects/0/FirstName";,
"type":"string"
 },
 "LastName":{
  

Re: [Dev] Issue in representing an array which contains non identical elements

2016-03-23 Thread Susinda Perera
Online xsd generators[1] generate xsd as one object having all four
elements as child elements of urn:sObjects, without considering xsi:type.
https://devutilsonline.com/xsd-xml/generate-xsd-from-xml

On Wed, Mar 23, 2016 at 9:47 PM, Susinda Perera  wrote:

>
>
> On Wed, Mar 23, 2016 at 7:51 PM, Awanthika Senarath 
> wrote:
>
>> Even though these arrays are identical, AFAIS they may occur independent,
>>
>> as in we may have 5 of the first array with the three items and 3 of the
>> other array which is completely unrelated to the first array,
>>
>>
>> In that case is it okey to represent them as a single array?
>>
>> according to [1] it seems like the xsi:type attribute is not just any
>> attribute but something similar to a key word in XML. in that case IMO it
>> is not correct to represent these two arrays as a merged array instance.
>>
> The xsi:type attribute is used to identify derived complex types[1]. In
> this example we have 2  objects which have different
> xsi:types. (i.e one does not have a xsi:type but other one
> having xsi:type="urn1:Contact") Therefore these two are different
> objects even though it has same name.
> However by looking at the given xml we can not say that it's xsd would
> have  array or single element because in this example we
> have only one object from each. Shall we add and object of 
> and check?
>
> [1] -
> http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.xmleditor.doc.user%2Ftopics%2Ftxsityp.html
>
>
>>
>> We need to consider xsi:type attribute as a keyword. I dont know how
>> viable this is though.
>>
>>
>>
>>
>>
>> [1]
>> http://stackoverflow.com/questions/21216778/how-to-define-xsitype-as-an-attribute-in-xml-schema
>>
>> Regards
>> Awanthika
>>
>>
>>
>> Awanthika Senarath
>> Software Engineer, WSO2 Inc.
>> Mobile: +94717681791
>>
>>
>>
>> On Wed, Mar 23, 2016 at 7:17 PM, Sohani Weerasinghe 
>> wrote:
>>
>>> Hi All,
>>>
>>> If we consider the below xml, "urn:sObjects" is an array which contains
>>> elements which are not identical.
>>>
>>> First array contains AccountId, FirstName, LastName and the other array
>>> contains Name.
>>>
>>>  >> xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"  xmlns:xsi="
>>> http://www.w3.org/2001/XMLSchema-instance";>
>>>  
>>>
>>>001D00HRzKD
>>>Jane
>>>Doe
>>> 
>>> 
>>>Acme Rockets, Inc.
>>> 
>>>  
>>>
>>> The generated json schema would be as follows
>>>
>>> {
>>>"$Schema":"http://json-schema.org/draft-04/schema#";,
>>>"title":"urn:create",
>>>"id":"http://jsonschema.net";,
>>>"type":"object",
>>>"properties":{
>>>   "urn:create":{
>>>  "id":"http://jsonschema.net/urn:create";,
>>>  "type":"object",
>>>  "properties":{
>>> "urn:sObjects":{
>>>"id":"http://jsonschema.net/urn:create/urn:sObjects";,
>>>"type":"array",
>>>"items":[
>>>   {
>>>  "id":"
>>> http://jsonschema.net/urn:create/urn:sObjects/0";,
>>>  "type":"object",
>>>  "properties":{
>>> "AccountId":{
>>>"id":"
>>> http://jsonschema.net/urn:create/urn:sObjects/0/AccountId";,
>>>"type":"string"
>>> },
>>> "@type":{
>>>"id":"
>>> http://jsonschema.net/urn:create/urn:sObjects/0/@type";,
>>>"type":"string"
>>> },
>>> "FirstName":{
>>>"id":"
>>> http://jsonschema.net/urn:create/urn:sObjects/0/FirstName";,
>>>"type":"string"
>>> },
>>> "LastName":{
>>>"id":"
>>> http://jsonschema.net/urn:create/urn:sObjects/0/LastName";,
>>>"type":"string"
>>> }
>>>  }
>>>   },
>>>   {
>>>  "id":"
>>> http://jsonschema.net/urn:create/urn:sObjects/0";,
>>>  "type":"object",
>>>  "properties":{
>>> "@type":{
>>>"id":"
>>> http://jsonschema.net/urn:create/urn:sObjects/0/@type";,
>>>"type":"string"
>>> },
>>> "Name":{
>>>"id":"
>>> http://jsonschema.net/urn:create/urn:sObjects/0/Name";,
>>>"type":"string"
>>> }
>>>  }
>>>   }
>>>]
>>> }
>>>  }
>>>   }
>>>},
>>>"namespaces":[
>>>   {
>>>  "prefix":"urn",
>>>  "url":"urn:enterprise.soap.sforce.com"
>>>   },
>>>   {
>>>  

Re: [Dev] Issue in representing an array which contains non identical elements

2016-03-23 Thread Susinda Perera
On Wed, Mar 23, 2016 at 7:51 PM, Awanthika Senarath 
wrote:

> Even though these arrays are identical, AFAIS they may occur independent,
>
> as in we may have 5 of the first array with the three items and 3 of the
> other array which is completely unrelated to the first array,
>
>
> In that case is it okey to represent them as a single array?
>
> according to [1] it seems like the xsi:type attribute is not just any
> attribute but something similar to a key word in XML. in that case IMO it
> is not correct to represent these two arrays as a merged array instance.
>
The xsi:type attribute is used to identify derived complex types[1]. In
this example we have 2  objects which have different
xsi:types. (i.e one does not have a xsi:type but other one
having xsi:type="urn1:Contact") Therefore these two are different
objects even though it has same name.
However by looking at the given xml we can not say that it's xsd would have
 array or single element because in this example we have only
one object from each. Shall we add and object of  and check?

[1] -
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.xmleditor.doc.user%2Ftopics%2Ftxsityp.html


>
> We need to consider xsi:type attribute as a keyword. I dont know how
> viable this is though.
>
>
>
>
>
> [1]
> http://stackoverflow.com/questions/21216778/how-to-define-xsitype-as-an-attribute-in-xml-schema
>
> Regards
> Awanthika
>
>
>
> Awanthika Senarath
> Software Engineer, WSO2 Inc.
> Mobile: +94717681791
>
>
>
> On Wed, Mar 23, 2016 at 7:17 PM, Sohani Weerasinghe 
> wrote:
>
>> Hi All,
>>
>> If we consider the below xml, "urn:sObjects" is an array which contains
>> elements which are not identical.
>>
>> First array contains AccountId, FirstName, LastName and the other array
>> contains Name.
>>
>>  > xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"  xmlns:xsi="
>> http://www.w3.org/2001/XMLSchema-instance";>
>>  
>>
>>001D00HRzKD
>>Jane
>>Doe
>> 
>> 
>>Acme Rockets, Inc.
>> 
>>  
>>
>> The generated json schema would be as follows
>>
>> {
>>"$Schema":"http://json-schema.org/draft-04/schema#";,
>>"title":"urn:create",
>>"id":"http://jsonschema.net";,
>>"type":"object",
>>"properties":{
>>   "urn:create":{
>>  "id":"http://jsonschema.net/urn:create";,
>>  "type":"object",
>>  "properties":{
>> "urn:sObjects":{
>>"id":"http://jsonschema.net/urn:create/urn:sObjects";,
>>"type":"array",
>>"items":[
>>   {
>>  "id":"
>> http://jsonschema.net/urn:create/urn:sObjects/0";,
>>  "type":"object",
>>  "properties":{
>> "AccountId":{
>>"id":"
>> http://jsonschema.net/urn:create/urn:sObjects/0/AccountId";,
>>"type":"string"
>> },
>> "@type":{
>>"id":"
>> http://jsonschema.net/urn:create/urn:sObjects/0/@type";,
>>"type":"string"
>> },
>> "FirstName":{
>>"id":"
>> http://jsonschema.net/urn:create/urn:sObjects/0/FirstName";,
>>"type":"string"
>> },
>> "LastName":{
>>"id":"
>> http://jsonschema.net/urn:create/urn:sObjects/0/LastName";,
>>"type":"string"
>> }
>>  }
>>   },
>>   {
>>  "id":"
>> http://jsonschema.net/urn:create/urn:sObjects/0";,
>>  "type":"object",
>>  "properties":{
>> "@type":{
>>"id":"
>> http://jsonschema.net/urn:create/urn:sObjects/0/@type";,
>>"type":"string"
>> },
>> "Name":{
>>"id":"
>> http://jsonschema.net/urn:create/urn:sObjects/0/Name";,
>>"type":"string"
>> }
>>  }
>>   }
>>]
>> }
>>  }
>>   }
>>},
>>"namespaces":[
>>   {
>>  "prefix":"urn",
>>  "url":"urn:enterprise.soap.sforce.com"
>>   },
>>   {
>>  "prefix":"xsi",
>>  "url":"http://www.w3.org/2001/XMLSchema-instance";
>>   },
>>   {
>>  "prefix":"urn1",
>>  "url":"urn:sobject.enterprise.soap.sforce.com"
>>   }
>>]
>> }
>>
>>
>> I am facing an issue in representing this in the tree view. Are we going
>> to add all 4 elements ( AccountId, FirstName, LastName and Name) under the
>> array object?
>>
>> Really appreciate

Re: [Dev] Issue in representing an array which contains non identical elements

2016-03-23 Thread Awanthika Senarath
Even though these arrays are identical, AFAIS they may occur independent,

as in we may have 5 of the first array with the three items and 3 of the
other array which is completely unrelated to the first array,


In that case is it okey to represent them as a single array?

according to [1] it seems like the xsi:type attribute is not just any
attribute but something similar to a key word in XML. in that case IMO it
is not correct to represent these two arrays as a merged array instance.

We need to consider xsi:type attribute as a keyword. I dont know how viable
this is though.





[1]
http://stackoverflow.com/questions/21216778/how-to-define-xsitype-as-an-attribute-in-xml-schema

Regards
Awanthika



Awanthika Senarath
Software Engineer, WSO2 Inc.
Mobile: +94717681791



On Wed, Mar 23, 2016 at 7:17 PM, Sohani Weerasinghe  wrote:

> Hi All,
>
> If we consider the below xml, "urn:sObjects" is an array which contains
> elements which are not identical.
>
> First array contains AccountId, FirstName, LastName and the other array
> contains Name.
>
>   xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"  xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance";>
>  
>
>001D00HRzKD
>Jane
>Doe
> 
> 
>Acme Rockets, Inc.
> 
>  
>
> The generated json schema would be as follows
>
> {
>"$Schema":"http://json-schema.org/draft-04/schema#";,
>"title":"urn:create",
>"id":"http://jsonschema.net";,
>"type":"object",
>"properties":{
>   "urn:create":{
>  "id":"http://jsonschema.net/urn:create";,
>  "type":"object",
>  "properties":{
> "urn:sObjects":{
>"id":"http://jsonschema.net/urn:create/urn:sObjects";,
>"type":"array",
>"items":[
>   {
>  "id":"http://jsonschema.net/urn:create/urn:sObjects/0
> ",
>  "type":"object",
>  "properties":{
> "AccountId":{
>"id":"
> http://jsonschema.net/urn:create/urn:sObjects/0/AccountId";,
>"type":"string"
> },
> "@type":{
>"id":"
> http://jsonschema.net/urn:create/urn:sObjects/0/@type";,
>"type":"string"
> },
> "FirstName":{
>"id":"
> http://jsonschema.net/urn:create/urn:sObjects/0/FirstName";,
>"type":"string"
> },
> "LastName":{
>"id":"
> http://jsonschema.net/urn:create/urn:sObjects/0/LastName";,
>"type":"string"
> }
>  }
>   },
>   {
>  "id":"http://jsonschema.net/urn:create/urn:sObjects/0
> ",
>  "type":"object",
>  "properties":{
> "@type":{
>"id":"
> http://jsonschema.net/urn:create/urn:sObjects/0/@type";,
>"type":"string"
> },
> "Name":{
>"id":"
> http://jsonschema.net/urn:create/urn:sObjects/0/Name";,
>"type":"string"
> }
>  }
>   }
>]
> }
>  }
>   }
>},
>"namespaces":[
>   {
>  "prefix":"urn",
>  "url":"urn:enterprise.soap.sforce.com"
>   },
>   {
>  "prefix":"xsi",
>  "url":"http://www.w3.org/2001/XMLSchema-instance";
>   },
>   {
>  "prefix":"urn1",
>  "url":"urn:sobject.enterprise.soap.sforce.com"
>   }
>]
> }
>
>
> I am facing an issue in representing this in the tree view. Are we going
> to add all 4 elements ( AccountId, FirstName, LastName and Name) under the
> array object?
>
> 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
>
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Issue in representing an array which contains non identical elements

2016-03-23 Thread Chanaka Fernando
Hi Sohani,

I think the representation which is in the json is correct. If you look at
this json message using a tool like [1], You can view that you have 2
elements in the array (of type sObjects). Within those elements, you can
have different elements. Adding all 4 elements under the same array is not
correct AFAIU.

[1] https://jsonformatter.curiousconcept.com/

On Wed, Mar 23, 2016 at 7:17 PM, Sohani Weerasinghe  wrote:

> Hi All,
>
> If we consider the below xml, "urn:sObjects" is an array which contains
> elements which are not identical.
>
> First array contains AccountId, FirstName, LastName and the other array
> contains Name.
>
>   xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"  xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance";>
>  
>
>001D00HRzKD
>Jane
>Doe
> 
> 
>Acme Rockets, Inc.
> 
>  
>
> The generated json schema would be as follows
>
> {
>"$Schema":"http://json-schema.org/draft-04/schema#";,
>"title":"urn:create",
>"id":"http://jsonschema.net";,
>"type":"object",
>"properties":{
>   "urn:create":{
>  "id":"http://jsonschema.net/urn:create";,
>  "type":"object",
>  "properties":{
> "urn:sObjects":{
>"id":"http://jsonschema.net/urn:create/urn:sObjects";,
>"type":"array",
>"items":[
>   {
>  "id":"http://jsonschema.net/urn:create/urn:sObjects/0
> ",
>  "type":"object",
>  "properties":{
> "AccountId":{
>"id":"
> http://jsonschema.net/urn:create/urn:sObjects/0/AccountId";,
>"type":"string"
> },
> "@type":{
>"id":"
> http://jsonschema.net/urn:create/urn:sObjects/0/@type";,
>"type":"string"
> },
> "FirstName":{
>"id":"
> http://jsonschema.net/urn:create/urn:sObjects/0/FirstName";,
>"type":"string"
> },
> "LastName":{
>"id":"
> http://jsonschema.net/urn:create/urn:sObjects/0/LastName";,
>"type":"string"
> }
>  }
>   },
>   {
>  "id":"http://jsonschema.net/urn:create/urn:sObjects/0
> ",
>  "type":"object",
>  "properties":{
> "@type":{
>"id":"
> http://jsonschema.net/urn:create/urn:sObjects/0/@type";,
>"type":"string"
> },
> "Name":{
>"id":"
> http://jsonschema.net/urn:create/urn:sObjects/0/Name";,
>"type":"string"
> }
>  }
>   }
>]
> }
>  }
>   }
>},
>"namespaces":[
>   {
>  "prefix":"urn",
>  "url":"urn:enterprise.soap.sforce.com"
>   },
>   {
>  "prefix":"xsi",
>  "url":"http://www.w3.org/2001/XMLSchema-instance";
>   },
>   {
>  "prefix":"urn1",
>  "url":"urn:sobject.enterprise.soap.sforce.com"
>   }
>]
> }
>
>
> I am facing an issue in representing this in the tree view. Are we going
> to add all 4 elements ( AccountId, FirstName, LastName and Name) under the
> array object?
>
> 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
>



-- 
Thank you and Best Regards,
Chanaka Fernando
Senior Technical Lead
WSO2, Inc.; http://wso2.com
lean.enterprise.middleware

mobile: +94 773337238
Blog : http://soatutorials.blogspot.com
LinkedIn:http://www.linkedin.com/pub/chanaka-fernando/19/a20/5b0
Twitter:https://twitter.com/chanakaudaya
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev