JiBX
  1. JiBX
  2. JIBX-222

Unable to eliminate empty parent element

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: JiBX 1.1.6
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Environment:
      N/A
    • Number of attachments :
      0

      Description

      I am defining a structure with a text value and an attribute value. When both associated fields are null, I don't want the resulting element to appear in the document. I have marked the structure and the two values as optional. When the two fields are null in my object, I get an empty element in my output.

        Activity

        Hide
        Dennis Sosnoski added a comment -

        This is a variation of the case described at http://jibx.sourceforge.net/bugs.html It's really an issue with ambiguity in the binding definition, since there's no way to directly tell JiBX that you don't want the enclosing element unless one or more of the contained values is present. The only way to make this work the way you want is by adding a test-method which will return true if either value is non-null, and false if they're both null.

        I'll try to come up with an approach which doesn't require any added user code for v2.

        Show
        Dennis Sosnoski added a comment - This is a variation of the case described at http://jibx.sourceforge.net/bugs.html It's really an issue with ambiguity in the binding definition, since there's no way to directly tell JiBX that you don't want the enclosing element unless one or more of the contained values is present. The only way to make this work the way you want is by adding a test-method which will return true if either value is non-null, and false if they're both null. I'll try to come up with an approach which doesn't require any added user code for v2.
        Hide
        James Watson added a comment -

        I have to defer to your expertise in this area given that you created this wonderful tool. Having said that, it seems to me that if the parent element is optional, it shouldn't show up in the output if none of its children are present. If that would cause issues, then I would say that if a parent element is optional and it contains required child elements, if those child elements are missing, the parent should not be output. I tried that kind of mapping setup and got a nasty stacktrace when I tried to serialize my object.

        Show
        James Watson added a comment - I have to defer to your expertise in this area given that you created this wonderful tool. Having said that, it seems to me that if the parent element is optional, it shouldn't show up in the output if none of its children are present. If that would cause issues, then I would say that if a parent element is optional and it contains required child elements, if those child elements are missing, the parent should not be output. I tried that kind of mapping setup and got a nasty stacktrace when I tried to serialize my object.

          People

          • Assignee:
            Dennis Sosnoski
            Reporter:
            James Watson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: