[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] Complex Mapping rules in MOXy?
|
Hello
all,
Now that I have some
basic XML-JAVA mappings working with MOXy, I have a more
challenging question.
What options are
available for solving the following mapping requirement?: "If a given element is
empty or null, populate domain model attribute with a concatenation of other
element values if these values are not null or empty."
The example below is
somewhat simplified but give the idea of what is required:
//XSD
snippet
<xs:complexType
name="Address">
<xs:sequence>
<xs:element
name="AddressLine01" type="xs:string"
minOccurs="0"/>
<xs:element name="AddressLine02"
type="xs:string" minOccurs="0"/>
<xs:element
name="HouseNbr" type="xs:string"
minOccurs="0"/>
<xs:element name="StreetDir"
type="xs:string" minOccurs="0"/>
<xs:element
name="StreetName" type="xs:string"
minOccurs="0"/>
<xs:element name="StreetSuffix"
type="xs:string" minOccurs="0"/>
<xs:element
name="RRNbr" type="xs:string"
minOccurs="0"/>
<xs:element name="POBox"
type="xs:string"
minOccurs="0"/>
</xs:sequence>
</xs:complexType>
// Java Domain Model
Attribute
setAddress01(String addr01)
//Pseudo-coded
Mapping Rules
if
xml.AddressLine01 IS NOT null AND xmlAddressLine01 IS
NOT empty
java.Address01 should be set to value
of xml.AddressLine01
else
if (xml.RRNbr IS null OR empty)
AND (xml.POBox IS null OR empty)
java.Address01
= (xml.HouseNbr + " ") +
if
(xml.StreetDir IS NOT null) AND (xml.StreetDir IS NOT
empty)
(xml.StreetDir + "
")
if (xml.StreetName IS NOT null)
AND (xml.StreetName IS NOT empty)
xml.StreetName
if (xml.StreetSuffix IS
NOT null) AND (xml.StreetSuffix IS NOT
empty)
(" " +
xml.StreetSuffix)
I've been very
pleased with what I could accomplish in a short amount of time working with MOXy
but the solution to the above has me stumped.
Any suggestions
would be greatly appreciated.
Regards,
Bill