Loading...

jibx-users@lists.sourceforge.net

[Prev] Thread [Next]  |  [Prev] Date [Next]

[jibx-users] JiBX bind - Error: factory-method needed for abstract type JackCY Tue Feb 07 09:09:43 2012

A simple example of a JiBX fail that I can't find a solution to. I have a
schema (simplified):

<?xml version="1.0" encoding="windows-1252"?>
<xs:schema xmlns="AAA" xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="AAA">
        <xs:complexType name="Generic_XSD">
        <xs:sequence/>
        <xs:attribute name="id" type="xs:ID"/>
        <xs:attribute name="ref" type="xs:IDREF"/>
    </xs:complexType>
    <xs:complexType name="Representation" abstract="true">
        <xs:complexContent>
            <xs:extension base="Generic_XSD">
                <xs:sequence/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="Property" abstract="true">
        <xs:complexContent>
            <xs:extension base="Generic_XSD">
                <xs:sequence>
                    <xs:element name="ofType" type="Representation"/>
                    <xs:element name="isARedeclarationOf"
type="Property" minOccurs="0"/>
                </xs:sequence>
                <xs:attribute name="name" type="xs:string"/>
                <xs:attribute name="optional" type="xs:boolean"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
</xs:schema>

This schema generates this binding file and java classes:

01<binding xmlns:ns2="AAA" name="binding" package="aaa" trim-whitespace="true">
02  <mapping abstract="true" type-name="ns2:Generic_XSD" class="aaa.GenericXSD">
03    <value style="attribute" name="id" get-method="getId"
set-method="setId" usage="optional"/>
04    <value style="attribute" name="ref" get-method="getRef"
set-method="setRef" usage="optional"/>
05  </mapping>
06  <mapping abstract="true" type-name="ns2:Representation"
class="aaa.Representation">
07    <structure map-as="ns2:Generic_XSD"/>
08  </mapping>
09  <mapping abstract="true" type-name="ns2:Property" class="aaa.Property">
10    <structure map-as="ns2:Generic_XSD"/>
11    <structure map-as="ns2:Representation" get-method="getOfType"
set-method="setOfType" name="ofType"/>
12    <structure map-as="ns2:Property"
get-method="getIsARedeclarationOf" set-method="setIsARedeclarationOf"
usage="optional" name="isARedeclarationOf"/>
13    <value style="attribute" name="name" get-method="getName"
set-method="setName" usage="optional"/>
14    <value style="attribute" name="optional"
get-method="getOptional" set-method="setOptional" usage="optional"/>
15  </mapping>
16</binding>

When the binding starts it throws this error:

[INFO] Running JiBX binding compiler (single-module mode) on 1 binding file(s)
Error: factory-method needed for abstract type 'aaa.Representation';
on structure element at (line 11, col 105, in binding.xml)
Error: factory-method needed for abstract type 'aaa.Property'; on
structure element at (line 12, col 152, in binding.xml)
Error: factory-method needed for abstract type 'aaa.Property'; on
structure element at (line 12, col 152, in binding.xml)

Anybody has an idea how to resolve this?

   - I can make changes to XSD - *not* preferred.
   - Customize the JiBX codegen/binding *preferred*.

*What changes do I need to do for it to work correctly?*

I really don't get it why the compiling does not generate all the things
that the binding needs like it does with JAXB.
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users