JiBX
  1. JiBX
  2. JIBX-142

Optional collection component requires a test-method , but it is ignored if specified

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JiBX 1.1
    • Fix Version/s: JiBX 1.1.3
    • Component/s: core
    • Labels:
      None
    • Environment:
      WinXP
    • Number of attachments :
      0

      Description

      <?xml version="1.0" encoding="UTF-8"?>
      <binding forwards="false" value-style="attribute">
      <mapping class="PropertyInteger" name="property-integer">
      <value style="attribute" name="name" field="m_name" usage="required"/>
      <value style="attribute" name="value" field="m_value" type="java.lang.Integer" usage="required"/>
      <value style="attribute" name="default-value" field="m_defaultValue" type="java.lang.Integer" usage="required"/>
      <value style="element" name="comment" field="m_comment" usage="optional"/>
      <structure name="range" field="m_range" type="RangeInteger" usage="required">
      <collection field="m_values" item-type="RangeItemInteger">
      <structure name="range-item" type="RangeItemInteger" usage="optional">
      <value style="attribute" name="min" field="m_minValue" type="java.lang.Integer" usage="optional"/>
      <value style="attribute" name="max" field="m_maxValue" type="java.lang.Integer" usage="optional"/>
      </structure>
      <structure name="item" type="RangeItemInteger" post-set="jibx_postSetMax2Min" test-method="isMinEqualToMax" usage="optional">
      <value style="attribute" name="val" field="m_minValue" type="java.lang.Integer" usage="optional"/>
      </structure>
      </collection>
      </structure>
      </mapping>
      </binding>

      JiBX binding output :
      ----------------------------

      Using bindings:
      binding.xml
      Running binding compiler version jibx_1_1
      Warning: Property access attributes (field, get-method, set-method, test-method) ignored for collection item; on structure element
      at (line 14, col 132, in binding.xml)
      Error: Collection component must specify a test-method to distinguish from next component of compatible type for marshalling; on s
      tructure element at (line 14, col 132, in binding.xml)
      Error running binding compiler
      org.jibx.runtime.JiBXException: Binding binding.xml is unusable because of validation errors
      at org.jibx.binding.Utility.loadBinding(Utility.java:346)
      at org.jibx.binding.Utility.loadFileBinding(Utility.java:413)
      at org.jibx.binding.Compile.compile(Compile.java:296)
      at org.jibx.binding.Compile.main(Compile.java:385)

      Purpose is to have a collection of generic RangeItemInteger instances with two fields m_minValue and m_maxValue and at the same time to be able to specify a XML shortcut for the case when the range is just a single value, i.e. m_minValue equals m_maxValue, instead of having to specify both m_minValue and m_maxValue, e.g. :

      ...
      <range>
      <range-item min="0" max="511"/>
      <range-item min="1000" max="1500"/>
      <range-item max="1500"/>
      <range-item min="1777"/>
      <range-item min="1778" max="1778"/>
      <item val="1779"/>
      </range>
      ...

        Activity

        Hide
        Dennis Sosnoski added a comment -

        I believe I've corrected the validation issues for this, though I don't have a convenient test case and haven't verified that it actually works now. If you can try it out with 1.1.2 please do so and report any further problems.

        Show
        Dennis Sosnoski added a comment - I believe I've corrected the validation issues for this, though I don't have a convenient test case and haven't verified that it actually works now. If you can try it out with 1.1.2 please do so and report any further problems.
        Hide
        Dennis Sosnoski added a comment -

        Incidentally, the test-method needs to go on the first ambiguous child component. I corrected the code so that the correct line number would show up in the output.

        Show
        Dennis Sosnoski added a comment - Incidentally, the test-method needs to go on the first ambiguous child component. I corrected the code so that the correct line number would show up in the output.
        Hide
        Dennis Sosnoski added a comment -

        No further feedback, so problem assumed to be corrected.

        Show
        Dennis Sosnoski added a comment - No further feedback, so problem assumed to be corrected.

          People

          • Assignee:
            Dennis Sosnoski
            Reporter:
            Marek
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: