Hi Jack,

The problem here is that your schema defines *abstract* types, which
cannot be used directly in XML documents. You need to have concrete
types that extend the abstract types in order to actually use them in
documents. Judging from the binding error you're getting, it looks like
there aren't any concrete types for these abstract types.

Are you working with the complete schema? How are these types used in
the actual instance documents? If the abstract types are never actually
used then you can just use a code generation customization to skip
generating the classes and bindings for these types.

  - Dennis

Dennis M. Sosnoski
Java SOA and Web Services Consulting <http://www.sosnoski.com/consult.html>
CXF and Web Services Security Training
<http://www.sosnoski.com/training.html>
Web Services Jump-Start <http://www.sosnoski.com/jumpstart.html>


On 02/08/2012 05:42 AM, JackCY wrote:
>
> 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
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to