| Summary: | MOXy: Issues with Self Mappings and XPaths to same name | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | David McCann <david.mccann> | ||||||||||
| Component: | Eclipselink | Assignee: | Blaise Doughan <blaise.doughan> | ||||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||||
| Severity: | normal | ||||||||||||
| Priority: | P3 | CC: | eclipselink.oxm-inbox | ||||||||||
| Version: | unspecified | ||||||||||||
| Target Milestone: | --- | ||||||||||||
| Hardware: | PC | ||||||||||||
| OS: | Windows XP | ||||||||||||
| Whiteboard: | |||||||||||||
| Attachments: |
|
||||||||||||
(In reply to comment #0) > Given the following model classes: > > @XmlRootElement(name="PaymentInf") > public class PaymentInf { > @XmlPath("id/text()") > public String id; > @XmlPath(".") > public Creditor creditor; > } > > > @XmlRootElement > public class Creditor { > @XmlPath("id/text()") > private String id; > } > > And the following xml instance document: > > <PaymentInf> > <id>pmtid</id> > <creditor> > <id>frstId</id> > </creditor> > </PaymentInf> > > We would expect that, upon unmarshal, PaymentInf.id would be "pmtid" and > Creditor.id would be "frstId". However, this is not the case; PaymentInf.id > is "" and Creditor.id is "frstIdfrstId". Should be: public class Creditor { @XmlPath("creditor/id/text()") private String id; } Workarounds: 1) rename one or more 'id' field XPaths such that the are different. 2) map one of the 'id' fields to an attribute. Created attachment 185878 [details]
test case
Created attachment 186411 [details]
Core - Fix
Created attachment 186432 [details]
Core - Fix
Created attachment 186567 [details]
MOXy - Test Cases
Fix checked into trunk at rev: 8802 Code reviewed by: David McCann Normally during an unmarshal when unmapped content is found, an unmapped content handler is set on the XMLReader. When the marshal record has self records this can not occur. In these cases a flag has been added to UnmarshalRecord to keep track of being in an unmapped state, this is done by level. Fix checked into 2.2.1 at rev: 9168 The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Given the following model classes: @XmlRootElement(name="PaymentInf") public class PaymentInf { @XmlPath("id/text()") public String id; @XmlPath(".") public Creditor creditor; } @XmlRootElement public class Creditor { @XmlPath("id/text()") private String id; } And the following xml instance document: <PaymentInf> <id>pmtid</id> <creditor> <id>frstId</id> </creditor> </PaymentInf> We would expect that, upon unmarshal, PaymentInf.id would be "pmtid" and Creditor.id would be "frstId". However, this is not the case; PaymentInf.id is "" and Creditor.id is "frstIdfrstId".