Re: XML attribute value indirection
List for Users of Carlsbad Cubes' Technologies and Products <[email protected]> Tue, 11 Oct 2005 18:44:36 -0600
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Message-ID | <[email protected]> |
--===============2144775532== Content-Type: multipart/alternative; boundary="----=_Part_13519_15023195.1129077876401" ------=_Part_13519_15023195.1129077876401 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Thx for weighing in on this Wolf. I agree that localization better not be confused w/ indirection. Still, I need indirection because it helps me centralize setting things and helps avoid much duplication. And as we all know duplication is the enemy o= f maintainability. I was hoping we'd somehow agree to address this need (I'm not hung up on the implementation details ;-). The solution you propose, namely that I write my own font converter does no= t scale well. After all, if I want to code this stuff directly, then I can do away w/ the XML file altogether. Regards, -Babak. On 10/11/05, List for Users of Carlsbad Cubes' Technologies and Products < [email protected]> wrote: > > After talking with a couple Swixml developers offline, I don't think we > should > implement general attribute indirection like is was proposed in this > thread. > > I don't want to see localization to be confused or mixed with using > 'indirect > attributes values', basically trying to use localizaion as a string > pre-processor. > > If you want to flag attribute values that require localization with an '@= ' > character, you are free to do so, by prefixing your keys with an @ > character > too. > > If you want to <i>'sprinkled font=3D"SansSerif--12" liberally everywhere > across > the file'</i>, I suggest you simply overwrite the FontConverter. > > Changing the Parsers behavior in respect to which attr. are considered fo= r > Localization is as simple as adding or removing attribute names to/from > the > public vector: Parser.LOCALIZED_ATTRIBUTES > > /** > * Localiced Attributes > */ > public static final Vector LOCALIZED_ATTRIBUTES =3D new Vector(); > > Converter classes are extreemly simple pieces of code and should be > replaced > (unregistered) or overwritten, if this kind of speacial functionality is > needed. > > BTW, the Class parameter is used somewhere, I think in the > PrimitiveConverter. > Moreover, the converter model was built with the idea that developers > would > implement there own converters, we wanted to make them as flex. as > possible and > therefore added the Class param... > > -- > Wolf Paulus > 707.202.3937 > [email protected] > > C a r l s b a d C u b e s > Dedicated to Excellence > > > > Quoting List for Users of Carlsbad Cubes' Technologies and Products > <[email protected]>: > > >> > >> I assume you would like to change the Converter.convert(Class, > Attribute, > >> Localizer) to > >> Converter.convert(Class, Attribute, Object localizedAttributeValue), > >> correct? > >> > > > > Actually, I was thinking the change would look more like > > > > Converter.convert(Class, Attribute) > > > > The reason why I thought this way is that the Parser only deals w/ > strings; > > and the Converters' job is to turn those strings into other kinds of > objects. > > > > The Parser (as demo-ed unclearly in the diff I submitted) just examines > > the attribute value, and if that value needs to be "translated", it jus= t > > replaces the translated value with the original: > > > > > > < String key =3D attr.getValue(); > > < String value =3D getChainedLocalizer().getString(key); > > < if (!key.equals(value)) > > < attr.setValue(value); > > > > > > -Babak. > > > > P.S. On a separate note--but while we're on the topic-- I'm not sure > > I understand what role the "Class" parameter in Converter.convert() > plays? > > After all, by the time we pick the right Converter, we already know > > what type it will be converting to... (It's not like the caller can > > *tell* the > > implementation which type to convert to, and I can't find a single plac= e > > where a Converter implementation uses this parameter...) > > > > _______________________________________________ > > Forum mailing list > > [email protected] > > http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com > > > > > > > _______________________________________________ > Forum mailing list > [email protected] > http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com > ------=_Part_13519_15023195.1129077876401 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Thx for weighing in on this Wolf.<br> <br> I agree that localization better not be confused w/ indirection.<br> <br> Still, I <span style=3D"font-weight: bold;">need </span>indirection because it helps me centralize setting things and helps avoid much duplication. And as we all know duplication is the enemy of maintainability. <span style=3D"font-style: italic;"> I was hoping we'= d somehow agree to address this need</span> (I'm not hung up on the impleme= ntation details ;-).<br> <br> The solution you propose, namely that I write my own font converter does not scale well. After all, if I want to code this stuff directly, then I can do away w/ the XML file altogether.<br> <br> Regards,<br> -Babak.<br><br><div><span class=3D"gmail_quote">On 10/11/05, <b class=3D"gm= ail_sendername">List for Users of Carlsbad Cubes' Technologies and Products= </b> <<a href=3D"mailto:[email protected]">[email protected]= </a> > wrote:</span><blockquote class=3D"gmail_quote" style=3D"border-left: 1= px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"= >After talking with a couple Swixml developers offline, I don't think we sh= ould <br>implement general attribute indirection like is was proposed in this th= read.<br><br>I don't want to see localization to be confused or mixed with = using 'indirect<br>attributes values', basically trying to use localizaion = as a string <br>pre-processor.<br><br>If you want to flag attribute values that require= localization with an '@'<br>character, you are free to do so, by prefixing= your keys with an @ character<br>too.<br><br>If you want to <i>'spri= nkled font=3D"SansSerif--12" liberally everywhere across <br>the file'</i>, I suggest you simply overwrite the FontConverter.<= br><br>Changing the Parsers behavior in respect to which attr. are consider= ed for<br>Localization is as simple as adding or removing attribute names t= o/from the <br>public vector: Parser.LOCALIZED_ATTRIBUTES<br><br> /**<br>&n= bsp; * Localiced Attributes<br> */<br> public = static final Vector LOCALIZED_ATTRIBUTES =3D new Vector();<br><br>Converter= classes are extreemly simple pieces of code and should be replaced <br>(unregistered) or overwritten, if this kind of speacial functionality i= s<br>needed.<br><br>BTW, the Class parameter is used somewhere, I think in = the PrimitiveConverter.<br>Moreover, the converter model was built with the= idea that developers would <br>implement there own converters, we wanted to make them as flex. as<br>p= ossible and<br>therefore added the Class param...<br><br>--<br>Wolf Paulus<= br>707.202.3937<br><a href=3D"mailto:[email protected]">wolf@carlsbadc= ubes.com </a><br><br>C a r l s b a d C u b e s<br>Dedicated to Excellence= <br><br><br><br>Quoting List for Users of Carlsbad Cubes' Technologies and = Products<br><<a href=3D"mailto:[email protected]">Forum@carlsbadcu= bes.com</a> >:<br><br>>><br>>> I assume you would like to change the Con= verter.convert(Class, Attribute,<br>>> Localizer) to<br>>> Conv= erter.convert(Class, Attribute, Object localizedAttributeValue),<br>>>= ; correct? <br>>><br>><br>> Actually, I was thinking the change would look= more like<br>><br>> Converter.convert(Class, Attribute)<br>><br>&= gt; The reason why I thought this way is that the Parser only deals w/ stri= ngs; <br>> and the Converters' job is to turn those strings into other kinds = of objects.<br>><br>> The Parser (as demo-ed unclearly in the diff I = submitted) just examines<br>> the attribute value, and if that value nee= ds to be "translated", it just <br>> replaces the translated value with the original:<br>><br>><b= r>> <  = ; String key =3D attr.getValue();<br>> <  = ; String value =3D getChainedLocalizer().getString(key);<br>> <  = ; if (!key.equals(value))<br>> <  = ; attr.setValue(value);<br>><br>><br>> -Babak.<br>><br>> P.S.&= nbsp; On a separate note--but while we're on the topic-- I'm not sure<= br>> I understand what role the "Class" parameter in Converter= .convert () plays?<br>> After all, by the time we pick the right Converter, we al= ready know<br>> what type it will be converting to... (It's n= ot like the caller can<br>> *tell* the<br>> implementation which type= to convert to, and I can't find a single place <br>> where a Converter implementation uses this parameter...)<br>><b= r>> _______________________________________________<br>> Forum mailin= g list<br>> <a href=3D"mailto:[email protected]">Forum@carlsbadcub= es.com </a><br>> <a href=3D"http://carlsbadcubes.com/mailman/listinfo/forum_car= lsbadcubes.com">http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcub= es.com</a><br>><br><br><br><br><br>_____________________________________= __________ <br>Forum mailing list<br><a href=3D"mailto:[email protected]">Forum@= carlsbadcubes.com</a><br><a href=3D"http://carlsbadcubes.com/mailman/listin= fo/forum_carlsbadcubes.com">http://carlsbadcubes.com/mailman/listinfo/forum= _carlsbadcubes.com </a><br></blockquote></div><br> ------=_Part_13519_15023195.1129077876401-- --===============2144775532== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Forum mailing list [email protected] http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com --===============2144775532==--