JiBX
  1. JiBX
  2. JIBX-188

Binding Compiler: Upgrade to 1.1.5 from 1.1.3 forces name attribute on nested structures using map-as

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: JiBX 1.1.5
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Environment:
      Windows
      JDK 1.6
      Ant 1.7
    • Number of attachments :
      0

      Description

      A binding with:

      <?xml version="1.0" encoding="UTF-8"?>
      <binding forwards="false">
      <mapping class="com.foo.bar.ProductProxy" name="ProductProxy" ordered="false" flexible="true">
      <value name="catalogId" field="catalogId" />
      <value name="catalogProductId" field="catalogProductId" />
      <structure map-as="com.foo.bar.Product" />
      </mapping>
      <mapping class="com.foo.bar.UserProduct" name="UserProduct" ordered="false" flexible="true">
      <structure map-as="com.foo.bar.Product" />
      </mapping>
      <mapping abstract="true" class="com.foo.bar.Product" ordered="false">
      <value name="id" field="id" usage="optional" /><!-- Not provided on POST, hence optional -->
      <value name="version" field="version" usage="optional" />
      <value name="deleted" field="deleted" usage="optional" default="false" />
      <value name="name" field="name" />
      <value name="description" field="description" usage="optional" />
      <value name="price" field="price" usage="optional" />
      <value name="detailUrl" field="detailUrl" usage="optional" />
      <structure name="imageUrl" value-style="attribute">
      <value name="href" field="imageUrl" usage="optional" />
      </structure>
      </mapping>
      <mapping class="amazon.a3n.rest.ResultsList" name="results">
      <collection field="results" create-type="java.util.ArrayList" />
      </mapping>
      </binding>

      Worked fine with 1.1.3 but throws exception during compilation. I am mapping an abstract superclass and do not want to have an element for that superclass in the xml.

      [jibx-bind] Error: All child components must define element names for flexible='true'; on structure element at (line 6, col
      50, in Product.binding.xml)
      [jibx-bind] Error: All child components must define element names for flexible='true'; on structure element at (line 9, col
      50, in Product.binding.xml)
      [jibx-bind] Error running binding compiler
      [jibx-bind] org.jibx.runtime.JiBXException: Binding Product.binding.xml is unusable because of validation errors
      [jibx-bind] at org.jibx.binding.Utility.loadBinding(Utility.java:346)
      [jibx-bind] at org.jibx.binding.Utility.loadFileBinding(Utility.java:413)
      [jibx-bind] at org.jibx.binding.Compile.compile(Compile.java:296)
      [jibx-bind] at org.jibx.binding.ant.CompileTask.execute(CompileTask.java:248)
      [jibx-bind] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
      [jibx-bind] at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
      [jibx-bind] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [jibx-bind] at java.lang.reflect.Method.invoke(Method.java:597)
      [jibx-bind] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
      [jibx-bind] at org.apache.tools.ant.Task.perform(Task.java:348)
      [jibx-bind] at org.apache.tools.ant.Target.execute(Target.java:357)
      [jibx-bind] at org.apache.tools.ant.Target.performTasks(Target.java:385)
      [jibx-bind] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
      [jibx-bind] at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
      [jibx-bind] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      [jibx-bind] at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
      [jibx-bind] at org.apache.tools.ant.Main.runBuild(Main.java:698)
      [jibx-bind] at org.apache.tools.ant.Main.startAnt(Main.java:199)
      [jibx-bind] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
      [jibx-bind] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
      [jibx-bind]

        Activity

        Hide
        Dennis Sosnoski added a comment -

        The use of flexible="true" means that JiBX needs to be able to identify exactly which elements are an expected part of the binding and which are not (and should therefore be discarded). The binding validation check which you've encountered was added in order to avoid problems which could occur if components did not have names, which in your case occurs with the references to the abstract mapping for com.foo.bar.Product.

        Judging from your binding, you'd like to be able to handle the elements defined in the base class, along with those added by the subclasses, in any order, and to ignore any other elements. That's more involved than I'm willing to support with the current codebase. I'll see if I can implement this type of handling for JiBX 2.0.

        Show
        Dennis Sosnoski added a comment - The use of flexible="true" means that JiBX needs to be able to identify exactly which elements are an expected part of the binding and which are not (and should therefore be discarded). The binding validation check which you've encountered was added in order to avoid problems which could occur if components did not have names, which in your case occurs with the references to the abstract mapping for com.foo.bar.Product. Judging from your binding, you'd like to be able to handle the elements defined in the base class, along with those added by the subclasses, in any order, and to ignore any other elements. That's more involved than I'm willing to support with the current codebase. I'll see if I can implement this type of handling for JiBX 2.0.
        Dennis Sosnoski made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Dennis Sosnoski [ dsosnoski ]
        Resolution Won't Fix [ 2 ]
        Dennis Sosnoski made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Dennis Sosnoski
            Reporter:
            Ezra Epstein
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: