To answer my own question (in case it's helps someone), the trick is to
add test-method="something" to prevent the node from being created. e.g:
<structure name="person" test-method="hasPerson" usage="optional">
and
public boolean hasPerson() {
return (customerNumber != null) || (firstName != null) || (lastName !=
null);
}
Steve
On Thu, 12 Feb 2009, Steve Quirk wrote:
>
> In order to be compliant to the schema, I've got to eliminate an empty
> element tag (e.g. <element/>).
>
> Using the customer example from the tutorial, if I use the following binding:
>
> <mapping name="customer" class="Customer">
> <structure name="person" usage="optional">
> <value name="cust-num" field="customerNumber" usage="optional"/>
> <value name="first-name" field="firstName" usage="optional"/>
> <value name="last-name" field="lastName" usage="optional"/>
> </structure>
> <structure field="address">
> <value name="street" field="street1"/>
> <value name="city" field="city"/>
> <value name="state" field="state"/>
> <value name="zip" field="zip"/>
> </structure>
> <value name="phone" field="phone"/>
> </mapping>
>
> (Note there is no Person class, it's all on Customer).
>
> The following XML is produced when customerNumber, firstName and lastName are
> null:
>
> <customer>
> <person/>
> <street>12345 Happy Lane</street>
> <city>Plunk</city>
> <state>WA</state>
> <zip>98059</zip>
> <phone>888.555.1234</phone>
> </customer>
>
> How do I get rid of the empty <person/> element?
>
> The real problem is with a B2B schema that I can't change. Emitting the
> empty element causes the xml to fail schema validation. Any tips?
>
> Thanks
> Steve
>
>
>
>
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users