Rhino 1.6R6 has now been released . The older Rhino jar that is part of the current Helma 1.6 package contains a E4X bug that prevents attribute support from working properly. To use E4X with Helma, you therefore need to replace that jar with the newer version.
While all Helma related patches that were pending at the time have been committed to Rhino 1.6R6 in June, there since has been one more Helma related patch that didn't make it into the Rhino 1.6R6 release version.
So, here's a version of the Rhino 1.6R6 containing that E4X fix and the pending Helma related patch:
http://helma.zumbrunn.net/downloads/rhino16r6patched/rhino.jar
With that patched version placed at ./lib/rhino.jar of your Helma installation, you can now enjoy E4X in your server-side Javascript and for example turn your skins into XML objects. With the code below, you could then access a skin "foo.skin" as XML object using this syntax: this.views.foo
/** * Object containing the collection of available views * * @type Object */ Mocha.prototype.__defineGetter__('views',function() { var views = {}; var protos = this.getPrototypeChainAsNames(); var that = this; for (var proto in protos) { for (var skin in app.skinfiles[protos[proto]]) { if (!views[skin]) { views.__defineGetter__(skin, function(){ var s = skin; var obj = that; return function(){ return new XML(obj.renderSkinAsString(s)); }; }()); } } } return views; }) /** * Returns the prototype chain as a string array of prototype names * * @return Array */ function getPrototypeChainAsNames(){ return this.getPrototypeChain().map( function(proto){ return / (\w+)\]$/(proto.toString())[1]; }); } /** * Returns the prototype chain as an array * * @return Array */ function getPrototypeChain(){ var protoChain = []; var proto = this.__proto__; do { protoChain.push(proto); proto = proto.__proto__; } while (proto != Object.prototype) return protoChain; }31.7.2007, 11:34