You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Abhinav Garg <ag...@sapient.com> on 2007/08/01 10:55:06 UTC

Error setting version property in XmlObject (XmlValueOutOfRangeException)

Hi,

We're creating a Fpml document (XML based language for derivatives data
interchange) using XmlBeans 2.2.0.

In the process, we're creating a Document object, which extends
XmlObject itself. It looks like this:

Package org.fpml.x2005.fpml42;
public interface Document extends org.apache.xmlbeans.XmlObject
{
    public static final org.apache.xmlbeans.SchemaType type =
(org.apache.xmlbeans.SchemaType)schemaorg_apache_xmlbeans.system.sCEC361
6E2A28C8F8CDB80F655A406BBE.TypeSystemHolder.typeSystem.resolveHandle("do
cumentc55etype");
    
    org.fpml.x2005.fpML42.Document.Version.Enum getVersion();    
    org.fpml.x2005.fpML42.Document.Version xgetVersion();    
    void setVersion(org.fpml.x2005.fpML42.Document.Version.Enum
version);    
    void xsetVersion(org.fpml.x2005.fpML42.Document.Version version);
    
    public interface Version extends org.apache.xmlbeans.XmlToken
    {
        public static final org.apache.xmlbeans.SchemaType type =
(org.apache.xmlbeans.SchemaType)schemaorg_apache_xmlbeans.system.sCEC361
6E2A28C8F8CDB80F655A406BBE.TypeSystemHolder.typeSystem.resolveHandle("ve
rsion501eattrtype");
        
        org.apache.xmlbeans.StringEnumAbstractBase enumValue();
        void set(org.apache.xmlbeans.StringEnumAbstractBase e);
        
        static final Enum X_4_0 = Enum.forString("4-0");
        static final Enum X_4_1 = Enum.forString("4-1");
        static final Enum X_4_2 = Enum.forString("4-2");
        
        static final int INT_X_4_0 = Enum.INT_X_4_0;
        static final int INT_X_4_1 = Enum.INT_X_4_1;
        static final int INT_X_4_2 = Enum.INT_X_4_2;
        
        static final class Enum extends
org.apache.xmlbeans.StringEnumAbstractBase
        {
            public static Enum forString(java.lang.String s)
                { return (Enum)table.forString(s); }
            public static Enum forInt(int i)
                { return (Enum)table.forInt(i); }            
            private Enum(java.lang.String s, int i)
                { super(s, i); }
            
            static final int INT_X_4_0 = 1;
            static final int INT_X_4_1 = 2;
            static final int INT_X_4_2 = 3;
            
            public static final
org.apache.xmlbeans.StringEnumAbstractBase.Table table =
                new org.apache.xmlbeans.StringEnumAbstractBase.Table
            (
                new Enum[]
                {
                    new Enum("4-0", INT_X_4_0),
                    new Enum("4-1", INT_X_4_1),
                    new Enum("4-2", INT_X_4_2),
                }
            );
            private static final long serialVersionUID = 1L;
            private java.lang.Object readResolve() { return
forInt(intValue()); } 
        }
	.................// Factory code
        
    }
}

The implementation class DocumentImpl looks like this:

public class DocumentImpl extends
org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements
org.fpml.x2005.fpML42.Document
{
    
    public DocumentImpl(org.apache.xmlbeans.SchemaType sType)    {
        super(sType);
    }    
    private static final javax.xml.namespace.QName VERSION$0 = 
        new javax.xml.namespace.QName("", "version");

...............
...............// other implemented methods
    
    public void setVersion(org.fpml.x2005.fpML42.Document.Version.Enum
version)    {
        synchronized (monitor())  {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target =
(org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(VERSION
$0);
            if (target == null)  {
                target =
(org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(VERSION$
0);
            }
            target.setEnumValue(version);
        }
    }

    public static class VersionImpl extends
org.apache.xmlbeans.impl.values.JavaStringEnumerationHolderEx implements
org.fpml.x2005.fpML42.Document.Version    {
        
        public VersionImpl(org.apache.xmlbeans.SchemaType sType)  {
            super(sType, false);
        }        
        protected VersionImpl(org.apache.xmlbeans.SchemaType sType,
boolean b)   {
            super(sType, b);
        }
    }
}

Now, I'm trying to set the version in the Document object like

doc.setVersion(org.fpml.x2005.fpML42.Document.Version.X_4_2);

But, it throws a XmlValueOutOfRangeException 

org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException
	at
org.apache.xmlbeans.impl.values.JavaStringEnumerationHolderEx.set_enum(J
avaStringEnumerationHolderEx.java:68)
	at
org.apache.xmlbeans.impl.values.XmlObjectBase.set(XmlObjectBase.java:161
9)
	at
org.apache.xmlbeans.impl.values.XmlObjectBase.setEnumValue(XmlObjectBase
.java:1555)
	at
org.fpml.x2005.fpML42.impl.DocumentImpl.setVersion(DocumentImpl.java:72)

To eradicate this, I tried doing something like this before setting the
version:

doc.changeType(org.fpml.x2005.fpML42.Document.Version.type);

But, then it throws a XmlValueDisconnectedException

org.apache.xmlbeans.impl.values.XmlValueDisconnectedException
	at
org.apache.xmlbeans.impl.values.XmlObjectBase.check_orphaned(XmlObjectBa
se.java:1213)
	at
org.fpml.x2005.fpML42.impl.DocumentImpl.setVersion(DocumentImpl.java:65)

I've tried everything in my power o set the version in the document
object, but not able to do so. Now, I almost suspect that
It's a Xmlbeans bug. Could anyone provide me some help or guidance on
this please?


Thanks.

Regards,
Abhinav





Re: Error setting version property in XmlObject (XmlValueOutOfRangeException)

Posted by Jeff Lusted <jl...@star.le.ac.uk>.
Hi Abhinav!

On Wed, 2007-08-01 at 14:25 +0530, Abhinav Garg wrote:
> Now, I'm trying to set the version in the Document object like
> 
> doc.setVersion(org.fpml.x2005.fpML42.Document.Version.X_4_2);
> 
> But, it throws a XmlValueOutOfRangeException 

> 
> To eradicate this, I tried doing something like this before setting
> the version:
> 
> doc.changeType(org.fpml.x2005.fpML42.Document.Version.type);
> 
> But, then it throws a XmlValueDisconnectedException
> 

Sorry, I haven't been through all the code you made available. But you
might try this as a variation...

doc = (Document)doc.changeType( org.fpml.x2005.fpML42.Document.type ) ;
doc.setVersion(org.fpml.x2005.fpML42.Document.Version.X_4_2);

Regards
Jeff
-- 
Jeff Lusted               tel: +44 (0)116 252 5358
Astrogrid Project         mob: +44 (0)7973 492290
Dept Physics & Astronomy  email: jl99@star.le.ac.uk
University of Leicester   web: http://www.astrogrid.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org