castor

Sequences don't map to list type, just single instance

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Won't Fix
  • Affects Version/s: 1.1
  • Fix Version/s: 1.1.1
  • Component/s: XML code generator
  • Labels:
    None
  • Testcase included:
    yes
  • Number of attachments :
    2

Description

I'm really using the 1.1.1 snapshot (20070221.201903-3), not 1.1.

I have a simple schema with an element that defines a sequence of another element, which in 0.9.6 properly generated an ArrayList object. In this version, it just generates a single instance. I can't find a workaround for this, and I can't continue my work until this is resolved.

Issue Links

Activity

Hide
Werner Guttmann added a comment -

David, if you rename 'weightedChoice' to 'weightedChioce', the code generated will meet your expactations. It looks like code has been added to deal with a class generated as a result of a <xs:choice> definition, and by default such classes will have a suffix appended named 'Choice'. It seems like you have two choices hewre:

a) rename that element name (if that's an option at all).
b( Use a binding file to 'rename' the name of the member generated.

Show
Werner Guttmann added a comment - David, if you rename 'weightedChoice' to 'weightedChioce', the code generated will meet your expactations. It looks like code has been added to deal with a class generated as a result of a <xs:choice> definition, and by default such classes will have a suffix appended named 'Choice'. It seems like you have two choices hewre: a) rename that element name (if that's an option at all). b( Use a binding file to 'rename' the name of the member generated.
Hide
Werner Guttmann added a comment -

In other words, an elementBinding such as given below resolves that issue as well ....

<elementBinding name="/weightedChoice">
<java-class name="WeithedChoiceCustom" />
</elementBinding>

Show
Werner Guttmann added a comment - In other words, an elementBinding such as given below resolves that issue as well .... <elementBinding name="/weightedChoice"> <java-class name="WeithedChoiceCustom" /> </elementBinding>
Hide
Werner Guttmann added a comment -

As a rule, please try to avoid element/attribute names that have a 'Choice' suffix.

Show
Werner Guttmann added a comment - As a rule, please try to avoid element/attribute names that have a 'Choice' suffix.
Hide
David M. Karr added a comment -

I was able to get this to work with:

<elementBinding name="/weightedChoice">
<java-class name="WeightedChoiceCustom"/>
</elementBinding>

(I'm including this so someone who finds this later isn't confused by the slight misspelling in your example solution.)

However, I wouldn't consider just "won't fix" to be sufficient here. This situation has a high "surprise factor", and someone running into this same situation won't have a clue why it's not generating correct code. Can't you detect that an element name ends in "Choice" and emit a warning that this won't generate the expected code?

Show
David M. Karr added a comment - I was able to get this to work with: <elementBinding name="/weightedChoice"> <java-class name="WeightedChoiceCustom"/> </elementBinding> (I'm including this so someone who finds this later isn't confused by the slight misspelling in your example solution.) However, I wouldn't consider just "won't fix" to be sufficient here. This situation has a high "surprise factor", and someone running into this same situation won't have a clue why it's not generating correct code. Can't you detect that an element name ends in "Choice" and emit a warning that this won't generate the expected code?
Hide
Werner Guttmann added a comment -

Yes, if you create me a follow-up issue focusing on just that area .. , though I am not going to make any promises this can be easily fixed.

Show
Werner Guttmann added a comment - Yes, if you create me a follow-up issue focusing on just that area .. , though I am not going to make any promises this can be easily fixed.
Hide
Steven Dolg added a comment -

Patch resolving that issue.

The decision whether or not to create a list is no longer based on the name of the element.
Its rather analyser whether it is a choice or not.

Both master test suite and regression tests worked as before...

Show
Steven Dolg added a comment - Patch resolving that issue. The decision whether or not to create a list is no longer based on the name of the element. Its rather analyser whether it is a choice or not. Both master test suite and regression tests worked as before...
Hide
Werner Guttmann added a comment -

Just committed Steven's patch, removing the requirement to deal with name suffices 'Choice' in a special way.

Show
Werner Guttmann added a comment - Just committed Steven's patch, removing the requirement to deal with name suffices 'Choice' in a special way.
Hide
David M. Karr added a comment -

Excellent. I'll test the next snapshot as soon as I see it.

Show
David M. Karr added a comment - Excellent. I'll test the next snapshot as soon as I see it.
Hide
Werner Guttmann added a comment -

Just note that the snapshot I released a few minutes ago does not include this patch .. .,

Show
Werner Guttmann added a comment - Just note that the snapshot I released a few minutes ago does not include this patch .. .,
Hide
David M. Karr added a comment -

That was my assumption. I never saw an enhancement request for implementation of time travel .

Show
David M. Karr added a comment - That was my assumption. I never saw an enhancement request for implementation of time travel .
Hide
David M. Karr added a comment -

Just so it's clear, is this patch going to be integrated into a snapshot and upcoming release?

Show
David M. Karr added a comment - Just so it's clear, is this patch going to be integrated into a snapshot and upcoming release?
Hide
Werner Guttmann added a comment -

As it's been committed to SVN trunk already, it will be part of the next release (whether snapshot or not).

Show
Werner Guttmann added a comment - As it's been committed to SVN trunk already, it will be part of the next release (whether snapshot or not).

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: