tuscany-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Kurz <sku...@gmail.com>
Subject Re: JaxB Unmarshaller not working properly for xsi:nil
Date Tue, 05 Apr 2011 19:12:11 GMT
Padraig,

I think I see what you're saying.  It seems to me the issue is better
illustrated if we tweak your test case XML to look like:

    private static final String XMLWithNil =
        "<ns0:root xmlns:ns0=\"http://ns0\"
xmlns:ns2=\"http://www.example.com/IPO\">" + "<ns1:next
xmlns:ns1=\"http://ns1\">"
            + "<ns2:purchaseOrder
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:nil=\"true\" xsi:type=\"ns2:PurchaseOrderType\"/>"
           + "</ns1:next>"
          + "</ns0:root>";

If we unmarshal this to JAXB, we get an "empty" PurchaseOrderType
whereas if the xsi:type is not present, e.g."

    private static final String XMLWithNil =
        "<ns0:root xmlns:ns0=\"http://ns0\"
xmlns:ns2=\"http://www.example.com/IPO\">" + "<ns1:next
xmlns:ns1=\"http://ns1\">"
             + "<ns2:purchaseOrder
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:nil=\"true\" />"
           + "</ns1:next>"
          + "</ns0:root>";

then we get a 'null'.

This test, then, simulates the way that OMElementWrapperHandler would
unwrap a wrapper element then add xsi:type to each wrapper child.

This seems to be a better test than the one you suggested since your
xsi:type was not added to the <purchaseOrder> element being
unmarshalled (as a top-level element), but rather to its child,
<shipTo>.    So the fact that this child element was not defined with
nillable="true" in the schema means that you're not giving JAXB a
schema-valid payload, in which case I would think we're going to have
to live with the implementation details and will have a hard time
adjusting in Tuscany.

So.. assuming I've understood the issue correctly, I would start by
recommending that you open a JIRA to track the issue.

I could imagine possibly making a change to the Tuscany runtime to not
add xsi:type if xsi:nil="true", but would like to open the issue for
comment.  At some point we should see what, if anything, the JAXB spec
says for a usecase like this.

Thanks,
Scott

Mime
View raw message