Hello,

I'm dealing with rather large XML objects that have 10's of thousands of
elements. Instead of using a String object for each elements value, I'd like
to pass a different object that uses a byte[] and have xmlBeans call the
object's toString() method which does all the converting. This would save a
lot of memory. So, I'd like to sub-class the appropriate Impl.class (or
modify the src) generated by scomp such that it delegates the stringValue()
method to the object that is backed by a byte[]. This part is no problem.

The problem arises when calling a parent element's xmltext() method; it
returns a null value. I don't know much about how xmlbeans works
behind-the-scenes, but my guess is that my object with the byte[] needs to
make it to the cursor somehow?

Any ideas for this. Is there a better way to solve my problem?

Thanks,

Eddie


-------------------Code------------------

public class MyStringImpl extends
org.apache.xmlbeans.impl.values.JavaStringHolderEx implements test.MyString{
   private MyObject o;

   public MyStringImpl(org.apache.xmlbeans.SchemaType sType) {
       super(sType, false);
   }

   protected MyStringImpl(org.apache.xmlbeans.SchemaType sType, boolean b)
{
       super(sType, b);
   }

   public void setMyObject(MyObject o) {
       this.o = o;
   }

   public String stringValue() {
       o.toString();
   }

   public String compute_text(NamespaceManager namespaceManager) {
       return stringValue();
   }

   public XmlCursor newCursor() {
       XmlCursor c = super.newCursor();
       c.toNextToken();
       c.insertChars(stringValue());
       return c;
   }
}

Reply via email to