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 <susi...@wso2.com> 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 <susi...@wso2.com> wrote: > >> >> >> On Wed, Mar 23, 2016 at 7:51 PM, Awanthika Senarath <awanth...@wso2.com> >> 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 <urn:sObjects> 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 <urn:sObjects> array or single element because in this example we >> have only one object from each. Shall we add and object of <urn:sObjects> >> 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 <soh...@wso2.com> >>> 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. >>>> >>>> <urn:create xmlns:urn="urn:enterprise.soap.sforce.com" >>>> xmlns:urn1="urn:sobject.enterprise.soap.sforce.com" xmlns:xsi=" >>>> http://www.w3.org/2001/XMLSchema-instance"> >>>> <urn:sObjects xsi:type="urn1:Contact"> <!--Zero or more >>>> repetitions:--> >>>> <!--You may enter ANY elements at this point--> >>>> <AccountId>001D000000HRzKD</AccountId> >>>> <FirstName>Jane</FirstName> >>>> <LastName>Doe</LastName> >>>> </urn:sObjects> >>>> <urn:sObjects xsi:type="urn1:Account"> >>>> <Name>Acme Rockets, Inc.</Name> >>>> </urn:sObjects> >>>> </urn:create> >>>> >>>> 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 >>>> >>> >>> >> >> >> -- >> *Susinda Perera* >> Software Engineer >> B.Sc.(Eng), M.Sc(Computer Science), AMIE(SL) >> Mobile:(+94)716049075 >> Blog: susinda.blogspot.com >> WSO2 Inc. http://wso2.com/ >> Tel : 94 11 214 5345 Fax :94 11 2145300 >> >> > > > -- > *Susinda Perera* > Software Engineer > B.Sc.(Eng), M.Sc(Computer Science), AMIE(SL) > Mobile:(+94)716049075 > Blog: susinda.blogspot.com > WSO2 Inc. http://wso2.com/ > Tel : 94 11 214 5345 Fax :94 11 2145300 > >
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev