forum  

Re: [Forum] XML attribute value indirection

List for Users of Carlsbad Cubes' Technologies and Products
Fri, 21 Oct 2005 08:30:58 -0700

Frank,

My apologies. After ranting (just a little) earlier, I took a different tack - I wrote a tiny ResourceBundle, where handleGetObject
distinguishes between text="${foo}" and text=foo, as Babak needed. It was then easy enough to  do a swix.setResourceBundle(Bundle.Name). Your approach is much more sophisticated, but I couldn't figure out to overload ResoureBundle.getString any other way.

Do you have a (simple) workaround for Babak's Font=xxx problem? Again, I'm a newbie, but I just don't understand why all fields can't be exposed to indirection. By exposing "all", SwixML is giving the developer a choice, but he/she doesn't have to take advantage of it, nor is SwixML necessarily increasing complexity.

Steve

List for Users of Carlsbad Cubes' Technologies and Products wrote:
List for Users of Carlsbad Cubes' Technologies and Products <Forum@carlsbadcubes.com> schrieb am 20.10.05 17:21:11:
  
... Further, to have the xml files directly exposed directly, 
rather than bundled in a jar file is not acceptable (do you honestly 
want to let uses to fool around with the xml files?) . I was successful 
passing to swix.render a URL for the .xml from a jar file, but gave up 
trying to pass a translation file via URL.
    

Steve, I do not understand: You could not put your translation files
into a jar? If this is your only problem and reason for indirection, there
is a cure for that. Of course neither the xml files nor the .properties files
are'nt exposed to "fool around with".

Here are snippets from (one of) my build.xml:

  <property name="build.dir" location="build"/>
  ...
  <target name="dist" depends="..." description="...">
    <jar jarfile="${build.dir}/ipd-${version}.jar">
    	<manifest>
    		<attribute name="main-class" value="..."/>
    		<attribute name="class-path" value="..."/>
    	</manifest>
      <fileset dir="${build.dir}">
				<include name="**/*.class"/>
                                ...
      </fileset>
      <fileset dir="${resource.dir}">
				<include name="**/*.properties"/>
				<include name="**/*.gif"/>
				<include name="**/*.png"/>
				<include name="**/*.xml"/>
				<include name="**/*.xsl"/>
				<include name="**/*.txt"/>
				<include name="**/*.dtd"/>
				<exclude name="**/*.bak"/>
				<exclude name="**/*~"/>
      </fileset>
    </jar>
  </target>

  <path id="classpath">
    <pathelement path="${build.dir}" />
    <pathelement path="${resource.dir}" />
    <fileset dir="${lib.dir}" includes="**/*.jar" />
  </path>

  <target name="run" depends="compile" description="runs">
    <java fork="true" classname="..." classpathref="classpath"/>
  </target>

The bundle attributes in my swixml files are in no way special like:
<frame size="990,700" title="..." bundle="i18n.messages" id="mainframe"    
    defaultCloseOperation="WindowConstants.DO_NOTHING_ON_CLOSE">

My resource files are located (as you may have guessed) in
 ${resource.dir}/i18n/messages*.properties

To summarize, I do not have any other files than jar files to distribute my app
with (ok, one: a dtd file I cannot get rid of, but this matter is not swixml's). 
The jar/distribution subject can be resolved entirely without indirection...

  
        
Now if you ever change you mind, I would suggest button text="${ok} /> 
rather than button text="@ok" /> because it would allow for a more 
sophistacted buttontext="${how}${now}${brown}${cow}". This is not my 
idea, ini4j also allows "[EMAIL PROTECTED]/key}" if coming from the properties file 
and [EMAIL PROTECTED]/key} if coming from the environment. Very cool.
    

Hm, IMHO this can be done through a change to  StringConverter, just split
the text and call the localizer for each part...

Yours,

Frank
  
Steve


_______________________________________________
Forum mailing list
Forum@carlsbadcubes.com
http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com
    



_______________________________________________
Forum mailing list
Forum@carlsbadcubes.com
http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com


  
_______________________________________________
Forum mailing list
Forum@carlsbadcubes.com
http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com