JiBX
  1. JiBX
  2. JIBX-231

Missing required attibutes after unmarshalling

    Details

    • Type: Bug Bug
    • 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:
      java version "1.5.0_13"
    • Number of attachments :
      1

      Description

      After unmarshalling the enclosed file (dptest.xml) the required attributes are missing from elements Collection (name) and ConditionalProperties (condition, value). See and compare with the marshalled document (dptestout.xml) at lines 7, 96, 126 and 133.
      Attached is the whole project, build.xml is in bin/ and used binding is config/psdp.jibx.xml
      The output file is generated from test case DPTest.testUnmarshall() (from test folder).

        Activity

        Hide
        Pavol Šimo added a comment -

        The issue seems to be related to element nesting. Attributes are missing from element ConditionalProperties which is nested in another ConditionalProperties element (or Collection in Collection).
        But this is not only issue with unmarshalling! Manually setting these attributes to object tree and marshalling it does not show mentioned attributes too.

        Try this code:
        IBindingFactory bfact = BindingDirectory.getFactory(DisplayProfile.class);
        IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
        DisplayProfile dp = (DisplayProfile) uctx.unmarshalDocument(new FileInputStream("dptest.xml"), null);

        ConditionalProperties pr = new ConditionalProperties();
        pr.setCondition("client");pr.setValue("XML");
        ConditionalProperties pr1 = new ConditionalProperties();
        pr1.setCondition("locale");pr1.setValue("sk");
        StringProperty sp = new StringProperty();
        sp.setName("desktopContainer");sp.setValue("htmlsk");
        pr1.addChoice(sp);
        pr.addChoice(pr1);
        dp.getProperties().addChoice(pr);

        dp.marshallTo(new OutputStreamWriter(new FileOutputStream("dptestout.xml")));

        and check the resulting file.
        This is the relevant part:

        <ConditionalProperties condition="client" value="XML">
        <ConditionalProperties>
        <String name="desktopContainer" value="htmlsk"/>
        </ConditionalProperties>
        </ConditionalProperties>

        should be

        <ConditionalProperties condition="client" value="XML">
        <ConditionalProperties condition="locale" value="sk">
        <String name="desktopContainer" value="htmlsk"/>
        </ConditionalProperties>
        </ConditionalProperties>

        Show
        Pavol Šimo added a comment - The issue seems to be related to element nesting. Attributes are missing from element ConditionalProperties which is nested in another ConditionalProperties element (or Collection in Collection). But this is not only issue with unmarshalling! Manually setting these attributes to object tree and marshalling it does not show mentioned attributes too. Try this code: IBindingFactory bfact = BindingDirectory.getFactory(DisplayProfile.class); IUnmarshallingContext uctx = bfact.createUnmarshallingContext(); DisplayProfile dp = (DisplayProfile) uctx.unmarshalDocument(new FileInputStream("dptest.xml"), null); ConditionalProperties pr = new ConditionalProperties(); pr.setCondition("client");pr.setValue("XML"); ConditionalProperties pr1 = new ConditionalProperties(); pr1.setCondition("locale");pr1.setValue("sk"); StringProperty sp = new StringProperty(); sp.setName("desktopContainer");sp.setValue("htmlsk"); pr1.addChoice(sp); pr.addChoice(pr1); dp.getProperties().addChoice(pr); dp.marshallTo(new OutputStreamWriter(new FileOutputStream("dptestout.xml"))); and check the resulting file. This is the relevant part: <ConditionalProperties condition="client" value="XML"> <ConditionalProperties> <String name="desktopContainer" value="htmlsk"/> </ConditionalProperties> </ConditionalProperties> should be <ConditionalProperties condition="client" value="XML"> <ConditionalProperties condition="locale" value="sk"> <String name="desktopContainer" value="htmlsk"/> </ConditionalProperties> </ConditionalProperties>

          People

          • Assignee:
            Dennis Sosnoski
            Reporter:
            Pavol Šimo
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: