commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <>
Subject Re: Betwixt (XML tags not sorted)
Date Wed, 23 Jun 2004 21:57:36 GMT
On 22 Jun 2004, at 14:14, wrote:

> Hello,


> I'm using Betwixt to transform my classes in XML.
> But the tags that Betwixt creates are sorted alphabetically. What can 
> I do
> to generate tags without sorting or at least sorted the way I want?

unless you specify the mapping in a dot betwixt file (or map a bean 
with a BeanInfo), the order of the elements is determined by the way in 
which your JVM orders your bean's properties. since different JVMs 
choose different orders, this is a major PITA.

it's not very easy to obtain the actual order of the properties in the 
source file (does anyone know if this is actually possible using 
reflection?) but one of the betwixt long term TODO's has been to add a 
strategy plug to allow programmatic control over element order. it 
should be pretty easy to write and usually i'd step up but i'm very 
busy right now with multiple releases. maybe you'd like to give this 
task a go or maybe someone will step up but otherwise you'll have to 
create .betwixt files to specify the mapping.

> Other problem.
> When a attribute of a classe is empty, Betwixt shows me the tags like 
> this
> <emptyTag/>.
> Is there a way to show tags like this? <emptyTag></emptyTag>

if you can update to CVS HEAD or grab the next nightly, i've just added 
this enhancement (but i don't have time to add any docs about it right 
now). BeanWriter has a new property called endTagForEmptyElement. if 
you set this to true then empty tags should come out the way you need.

(hopefully i'll find time to write this feature up tomorrow.)

- robert

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message