I think it's better if we can use "ATR" instead of "ATT"
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 2, 2016 at 11:25 AM, Sohani Weerasinghe <soh...@wso2.com> wrote: > Hi All, > > When representing attributes in avro schema, according to [1] the > suggested approach is to use @ as a prefix. > > Since avro name should start with [A-Za-z] and subsequently contain only > [A-Za-z0-9_], shall we represent it as below (adding ATT as a prefix) > > "name" : "*ATT*_gender" > > [1] > https://docs.google.com/spreadsheets/d/15eyRuxn9rFazULASqtB2DZaSAVznKqSNnIGrwvdpzic/edit?ts=56d5250b#gid=0 > > 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 2, 2016 at 7:47 AM, Sohani Weerasinghe <soh...@wso2.com> > wrote: > >> >> Please find the attached image which represents the prefix in the tree >> view >> >> 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 2, 2016 at 7:45 AM, Sohani Weerasinghe <soh...@wso2.com> >> wrote: >> >>> >>> >>> 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 2, 2016 at 6:28 AM, Jasintha Dasanayake <jasin...@wso2.com> >>> wrote: >>> >>>> >>>> >>>> On Tue, Mar 1, 2016 at 9:07 PM, Sohani Weerasinghe <soh...@wso2.com> >>>> wrote: >>>> >>>>> Thanks Nuwan for the response. >>>>> >>>>> When generating the avro schema by adding elements to the tree view, >>>>> user can specify the namespace (xml namespace) with the prefix, so that >>>>> when generating the the avro schema we can map the namespace to doc and >>>>> prefix to the namespace in avro. >>>>> >>>> >>>> Yes that's mapping is fine , somehow we need to show at least prefix in >>>> the tree view otherwise user experience won't be nice since user have to >>>> check it explicitly while doing the mapping >>>> >>> >>> Yes, I have implemented that and the prefix will be shown in the tree >>> view. >>> >>>> >>>> Thanks and Regards >>>> /Jasintha. >>>> >>>>> >>>>> 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, Mar 1, 2016 at 8:54 PM, Nuwan Pallewela <nuw...@wso2.com> >>>>> wrote: >>>>> >>>>>> >>>>>> >>>>>> On Tue, Mar 1, 2016 at 7:34 PM, Sohani Weerasinghe <soh...@wso2.com> >>>>>> wrote: >>>>>> >>>>>>> Hi All, >>>>>>> >>>>>>> If we consider an XML which has multiple namespaces as below , >>>>>>> >>>>>>> <root> >>>>>>> <h:table xmlns:h="http://www.w3.org/TR/html4/"> >>>>>>> <h:name>Asian Coffee Table</h:name> >>>>>>> <h:width>74</h:width> >>>>>>> <h:length>129</h:length> >>>>>>> </h:table> >>>>>>> <f:table xmlns:f="http://www.w3schools.com/furniture"> >>>>>>> <f:name>African Coffee Table</f:name> >>>>>>> <f:width>80</f:width> >>>>>>> <f:length>120</f:length> >>>>>>> </f:table> >>>>>>> </root> >>>>>>> >>>>>>> The avro schema should be as follows , >>>>>>> >>>>>>> { >>>>>>> "type" : "record", >>>>>>> "name" : "root", >>>>>>> "fields" : [ { >>>>>>> "type" : "record", >>>>>>> "name" : "tableRecord", >>>>>>> * "doc" : "http://www.w3.org/TR/html4/ >>>>>>> <http://www.w3.org/TR/html4/>",* >>>>>>> "namespace" : "http://www.w3.org/TR/html4/" >>>>>>> "fields" : [ { >>>>>>> "name" : "name", >>>>>>> "type" : [ "null", "string" ] >>>>>>> "doc" : "http://www.w3.org/TR/html4/" >>>>>>> } , { >>>>>>> "name" : "width", >>>>>>> "type" : [ "null", "int" ] >>>>>>> },{ >>>>>>> "name" : "length", >>>>>>> "type" : [ "null", "int" ] >>>>>>> }] >>>>>>> }, { >>>>>>> "type" : "record", >>>>>>> "name" : "tableRecord", >>>>>>> * "doc" : "http://www.w3schools.com/furniture >>>>>>> <http://www.w3schools.com/furniture>",* >>>>>>> "namespace" : "http://www.w3schools.com/furniture" >>>>>>> "fields" : [ { >>>>>>> "name" : "name", >>>>>>> "type" : [ "null", "string" ] >>>>>>> } , { >>>>>>> "name" : "width", >>>>>>> "type" : [ "null", "int" ] >>>>>>> },{ >>>>>>> "name" : "length", >>>>>>> "type" : [ "null", "int" ] >>>>>>> }] >>>>>>> } ] >>>>>>> } >>>>>>> >>>>>>> When representing this using the Visual DataMapper Editor, in order >>>>>>> to differentiate the two records, we can add a namespace prefix to the >>>>>>> name >>>>>>> of the record as shown below. >>>>>>> >>>>>>> >>>>>>> But when generating the Avro Schema, if we pass this value as the >>>>>>> name of the node it throws *org.apache.avro.SchemaParseException: >>>>>>> Illegal character in: y:tableRecord.* >>>>>>> >>>>>> >>>>>> AVRO name should start with [A-Za-z] and subsequently contain only >>>>>> [A-Za-z0-9_]. >>>>>> So we can not pass name with namespace prefix. >>>>>> >>>>>>> >>>>>>> So, if we use only the name (tableRecord, by removing the prefix) to >>>>>>> create the avro schema, how are we going to differentiate the records >>>>>>> separately when generating the mapping config? >>>>>>> >>>>>> >>>>>> We should add above xml namespace prefix as the namespace of AVRO >>>>>> record. Then two elements can be differentiated. >>>>>> For Eg: >>>>>> >>>>>> { >>>>>> "type" : "record", >>>>>> "name" : "root", >>>>>> "fields" : [ { >>>>>> "type" : "record", >>>>>> "name" : "tableRecord", >>>>>> * "doc" : "http://www.w3.org/TR/html4/ >>>>>> <http://www.w3.org/TR/html4/>",* >>>>>> "namespace" : "N1", >>>>>> "fields" : [ { >>>>>> "name" : "name", >>>>>> "type" : [ "null", "string" ], >>>>>> "doc" : "http://www.w3.org/TR/html4/" >>>>>> } , { >>>>>> "name" : "width", >>>>>> "type" : [ "null", "int" ], >>>>>> "doc" : "http://www.w3.org/TR/html4/" >>>>>> },{ >>>>>> "name" : "length", >>>>>> "type" : [ "null", "int" ], >>>>>> "doc" : "http://www.w3.org/TR/html4/" >>>>>> }] >>>>>> }, { >>>>>> "type" : "record", >>>>>> "name" : "tableRecord", >>>>>> * "doc" : "http://www.w3schools.com/furniture >>>>>> <http://www.w3schools.com/furniture>",* >>>>>> "namespace" : "N2", >>>>>> "fields" : [ { >>>>>> "name" : "name", >>>>>> "type" : [ "null", "string" ], >>>>>> *"doc" : "http://www.w3schools.com/furniture >>>>>> <http://www.w3schools.com/furniture>"* >>>>>> } , { >>>>>> "name" : "width", >>>>>> "type" : [ "null", "int" ] >>>>>> *"doc" : "http://www.w3schools.com/furniture >>>>>> <http://www.w3schools.com/furniture>"* >>>>>> },{ >>>>>> "name" : "length", >>>>>> "type" : [ "null", "int" ], >>>>>> *"doc" : "http://www.w3schools.com/furniture >>>>>> <http://www.w3schools.com/furniture>"* >>>>>> }] >>>>>> } ] >>>>>> } >>>>>> >>>>>> Then the full names of the two tableRecords will be N1.tableRecord >>>>>> and N2.tableRecord and AVRO can differentiate these two fields. >>>>>> >>>>>>> >>>>>>> eg: If we are to map a field in y:tableRecord with a field >>>>>>> in y:tableRecord etc. How can we differentiate this? >>>>>>> >>>>>>> This usecase of having multiple namespaces can be displayed >>>>>>> graphically in the Design view by appending a namespace prefix, but it >>>>>>> seems this will have issues in generating the avro schema and the >>>>>>> mapping >>>>>>> config. >>>>>>> >>>>>> >>>>>> Mapping configuration does not need to be aware of the namespaces as >>>>>> long as they can be differentiate in the diagram. Output from the mapping >>>>>> will look into the output schema and will build the output message with >>>>>> desired namespaces. >>>>>> >>>>>>> >>>>>>> Your suggestions are highly appreciated. >>>>>>> >>>>>>> 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>@* >>>>>> >>>>>> >>>>>> >>>>> >>>> >>>> >>>> -- >>>> >>>> *Jasintha Dasanayake* >>>> >>>> *Senior Software EngineerWSO2 Inc. | http://wso2.com >>>> <http://wso2.com/>lean . enterprise . middleware* >>>> >>>> >>>> *mobile :- 0711368118 <0711368118>* >>>> >>> >>> >> >
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev