Codegen: Enumeration in imported schema can result in IllegalArgumentException: 
No enum const class
---------------------------------------------------------------------------------------------------

                 Key: JIBX-263
                 URL: http://jira.codehaus.org/browse/JIBX-263
             Project: JiBX
          Issue Type: Bug
          Components: core
    Affects Versions: JiBX 1.2
            Reporter: Nigel Charman


The problem occurs when a complex-type containing a string with an enum 
restriction is imported from another schema.  It happens consistently in one 
project, but I've been trying for most of the afternoon to reproduce it in a 
simpler form and can't make it fail outside the original project.

The project uses 4 schema. Schema C imports schema D.  Schema A imports both 
schema C and D.  Schema B also imports both schema C and D.  Schema D contains

   <xsd:simpleType name="version">
       <xsd:restriction base="xsd:string">
           <xsd:enumeration value="3.2"/>
           <xsd:enumeration value="3.3"/>
           <xsd:enumeration value="4.0"/>
       </xsd:restriction>
   </xsd:simpleType>

The generated binding.xml includes the bindings in the "wrong" order:

 <include path="binding D"/>
 <include path="binding C"/>
 <include path="binding B"/>
 <include path="binding A"/>

binding A contains:
 <format type="Version" enum-value-method="value"/>

bindings C and D contain:
   <value style="attribute" name="Version" get-method="getVersion" 
set-method="setVersion"/>

However, since C and D are included before A in binding.xml, they do not seem 
to know about the format of the Version enum. The resulting error is:

    [java] Exception in thread "main" java.lang.IllegalArgumentException: No 
enum const class xsd.simpletypes.Version.3.2
    [java]     at java.lang.Enum.valueOf(Enum.java:196)
    [java]     at xsd.simpletypes.Version.valueOf(Version.java:16)
    [java]     at xsd.svreq.MESSAGE.JiBX_binding_unmarshalAttr_1_0(MESSAGE.java)
    [java]     at xsd.svreq.JiBX_bindingMESSAGE_access.unmarshal()
    [java]     at 
org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2762)
    [java]     at 
org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2905)
    [java]     at Test.main(Test.java:25)

I can work around the issue by either adding the <format type="Version" 
enum-value-method="value"/> element to bindings C and D, or rearranging 
binding.xml to have the bindings in the order A, B, C, D.  When I try to 
reproduce the error in a simplified project, the code generator always seems to 
create the binding.xml in the order A, B, C, D. 

I can email you the project, but don't want to upload it publicly.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
jibx-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-devs

Reply via email to