3 Replies Latest reply on Jul 20, 2005 6:28 PM by starksm64

    Mapping attributes with default values

    starksm64

      See http://jira.jboss.com/jira/browse/JBXB-32 for an example issue. Currently if a schema defines attributes with default values, the defaults are not being set on the associated java object unless explicitly present in the xml document. This seems incorrect as it essentially makes the defaults non-existent.

      Is this info available from the schema api?

        • 1. Re: Mapping attributes with default values
          starksm64

          The answer is yes, its available via the XSAttributeUse.getConstraintValue, which for the attributes in the schema shown in the JBXB-32 issue are:

           Attr(type): , Required: false, ConstraintType: default, ConstraintValue: java.lang.String
           Attr(editor): , Required: false, ConstraintType: none, ConstraintValue: null
           Attr(replace): , Required: false, ConstraintType: default, ConstraintValue: true
           Attr(trim): , Required: false, ConstraintType: default, ConstraintValue: true
          


          Currently it looks like we are throwing this info away in the call to XsdBinder.bindAttributes. I think this is something that needs to be implemented for the 4.0.3 release so I'll look into it while Alexey is out.


          • 2. Re: Mapping attributes with default values
            starksm64

            I have added support for mapping missing attributes with defaults to head, and the org.jboss.test.xml.jbxb.defaults.DefaultsUnitTestCase is passing, but the org.jboss.test.xml.JNDIBindingUnitTestCase continues to fail because the java object stack and type stacks seem to be out of synch when it comes to the JNDIBinding object and associated jndi:binding element.

            • 3. Re: Mapping attributes with default values
              starksm64

              This is now working in head. After discussing some of the current behavior and getting it clear and documented this will be ported to 4.0 for the 4.0.3 release.