I am trying to write the following bean (OutterClass.java) to XML, but the
resulting XML is not what I want.

// base class for the two beans add to the collection
public interface BaseClass
{
}

// will be added to the collection
public class DerivedClassA implements BaseClass
{
}

public class DerivedClassB implements BaseClass
{
}

// the class to be converted to XML.
public class OutterClass
{
  Vector attributes = new Vector();

  public OutterClass()
  {
    attributes.add(new DerivedClassA());
    attributes.add(new DerivedClassB());
  }

  public  Vector getAttributes()
  {
    return attributes;
  }
}

// .betwixt file
<?xml version='1.0' encoding='UTF-8' ?>
<info>
<element name='MyOutterClass'>
 <addDefaults/>
</element>
</info>

// XML written.
<MyOutterClass>
  <MyDerivedClassA/>
  <DerivedClassB/>
</MyOutterClass>

The XML above is perfect, but when I add the following method below to
OutterClass...

 public void addAttribute(BaseClass attr)
 {
   attributes.add(attr);
 }


the XML output changes to...

<MyOutterClass>
  <attribute/>
  <attribute/>
</MyOutterClass>

----------------------------------------------------------------------------
---------------------------
I have also tried the following .betwixt file...

<?xml version='1.0' encoding='UTF-8' ?>
<info>
<element name='MyOutterClass'>
 <addDefaults add-adders='false'/>
</element>
</info>

but the XML output changes to...

<MyOutterClass/>



Any idea why this is happening and how to fix it?

Thanks
J


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to