Try again - not too familiar with gmail keyboard shortcuts!
On 21/10/05, James Abley <[EMAIL PROTECTED]> wrote:
> I'm using rc1. I've gone through the site documents and the mail archive.
> This is the closest that I've found, but I can't get it to work.
>
> http://marc.theaimsgroup.com/?l=jibx-users&m=112421869015776&w=2
>
> I have the following (simplified) class hierarchy:
>
> UserData - which I want marshalling to XML. This contains some simple
> fields and an array of Subscription objects.
>
> Subscription - defines core Subscription behaviour.
> CreditSubscription extends Subscription
> SingleCreditSubscription extends CreditSubscription
> MultiCreditSubscription extends CreditSubscription
> PositionSubscription extends Subscription
> CyclicSubscription extends PositionSubscription
> FixedTermSubscription extends CyclicSubscription
>
> I would like to be able to marshall all of my defined subscription
> subclasses as <subscription /> elements with a type attribute.
>
> I've defined this mapping file so far:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <binding>
> <mapping name="userData" class="com.example.users.UserData">
> <value name="name" get-method="getName" set-method="setName"/>
> <value name="joiningDate" get-method="getJoiningDate"
> set-method="setJoiningDate"/>
> <collection name="subscriptions" get-method="getSubscriptions"
> set-method="setSubscriptions" />
> </mapping>
>
> <mapping abstract="true" type-name="subscription-type"
> class="com.example.users.Subscription">
>
> <value name="createdDate" get-method="getCreatedDate"
> set-method="setCreatedDate" />
> </mapping>
>
> <mapping name="subscription" class="com.example.users.Subscription">
> <structure map-as="subscription-type" />
> </mapping>
>
> </binding>
>
>
I have to define a class attribute on the abstract mapping otherwise
the compile fails.
With the above binding xml file, I get the following when trying to
run the jibx compiler.
[bind] Using the following paths:
[bind]
/home/jabley/work/eclipse/workspace/jibx-learning/jibx-learning/built/output/classes/impl
[bind] Using the following binding paths:
[bind]
/home/jabley/work/eclipse/workspace/jibx-learning/build/jibx-bindings.xml
[bind] Running binding compiler version jibx-rc1
[bind] Error running binding compiler
[bind] *** Error during code generation - please report this
error on the JiBX users list so that the condition can be caught
during validation ***
[bind] org.jibx.runtime.JiBXException: Mapping references require
property definition at tag "structure"(line 25, col 49, in
jibx-bindings.xml)
[bind] at
org.jibx.runtime.impl.UnmarshallingContext.throwStartTagException(Unknown
Source)
[bind] at
org.jibx.binding.def.BindingBuilder.unmarshalStructure(BindingBuilder.java:1380)
[bind] at
org.jibx.binding.def.BindingBuilder.unmarshalStructureChildren(BindingBuilder.java:822)
[bind] at
org.jibx.binding.def.BindingBuilder.unmarshalMapping(BindingBuilder.java:1549)
[bind] at
org.jibx.binding.def.BindingBuilder.unmarshalMappings(BindingBuilder.java:950)
[bind] at
org.jibx.binding.def.BindingBuilder.unmarshalBindingDefinition(BindingBuilder.java:1735)
[bind] at org.jibx.binding.Utility.loadBinding(Utility.java:308)
[bind] at org.jibx.binding.Utility.loadFileBinding(Utility.java:388)
[bind] at org.jibx.binding.Compile.compile(Compile.java:296)
[bind] at org.jibx.binding.ant.CompileTask.execute(CompileTask.java:248)
[bind] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[bind] at org.apache.tools.ant.Task.perform(Task.java:364)
[bind] at org.apache.tools.ant.Target.execute(Target.java:341)
[bind] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[bind] at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[bind] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[bind] at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[bind] at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[bind] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[bind] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[bind] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
So I have a couple of questions really
1. What have I missed that's causing the above?
2. Should I be using an array, rather than a Collection type, if it's
going to contain subclasses; i.e. will they be mapped OK, once I get
past the first issue?
Regards,
James
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users