Hi Brett Maybe customizing the XMLIntrospector used by the BeanReader/BeanWriter could help give you XML more like you expect, such as
XMLIntrospector introspector = new XMLIntrospector(); introspector .setWrapCollectionsInElement(false); introspector.setAttributesForPrimitives(true); If that still gives you problems, any chance you could submit a little bit of Java code (preferably the JUnit test case you're running) of exactly what you're doing so it'd be easier to correct/fix? It'd be handy if created a 'Results' object and using the same introspector, showed how it outputs as XML also? James ------- http://radio.weblogs.com/0112098/ ----- Original Message ----- From: "Brett Porter" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, September 05, 2002 4:09 AM Subject: [Betwixt] Collections without .betwixt > Hi, > > I'm using Betwixt for the following sort of format XML: > > <results> > <company name="blah" /> > <company name="blah2" /> > </results> > > Now, if I have a results class with the following: > private java.util.Collection companyList new java.util.ArrayList(); > public void addCompany( Company c ) { companyList.add( c ); } > public java.util.Collection getCompanyList() { return companyList; } > > And a Company class with: > private String name; > public String getName() { return name; } > public void setName( String name ) { this.name = name; } > > and use a similar test class as the src/tests version (BeanReader then > BeanWriter) I get back: > > <results id="1"> > <companyList/> > </results> > > If I change the XML to have <companyList> around it, it seems ok, except > it can't deal with name as an attribute, it needs an element. > > If I specify a .betwixt file for results: > <?xml version="1.0"?> > <info primitiveTypes="attribute"> > <element name="results"> > <element name="company" property="companyList"> > <addDefaults/> > </element> > </element> > </info> > > ... it works as I expect. > > So, do I need the .betwixt file for each class, or am I missing > something? I don't care what the output is, but the bean is not being > built correctly without it. > > Thanks, > Brett Porter > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
