Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339596 - Extension: XPath Mapping with Predicates
Summary: Extension: XPath Mapping with Predicates
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 332770 340474 348114
  Show dependency tree
 
Reported: 2011-03-10 16:01 EST by Blaise Doughan CLA
Modified: 2022-06-09 10:32 EDT (History)
1 user (show)

See Also:


Attachments
Core - Fix (8.87 KB, patch)
2011-03-10 16:09 EST, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (9.67 KB, patch)
2011-03-10 16:42 EST, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (11.52 KB, application/octet-stream)
2011-03-11 11:41 EST, Blaise Doughan CLA
no flags Details
MOXy - Test Cases (16.36 KB, patch)
2011-03-14 12:55 EDT, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (11.61 KB, patch)
2011-03-14 12:55 EDT, Blaise Doughan CLA
no flags Details | Diff
MOXy - Test Cases (17.09 KB, patch)
2011-03-14 16:45 EDT, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (12.48 KB, patch)
2011-03-14 16:46 EDT, Blaise Doughan CLA
no flags Details | Diff
MOXy - Test Cases (34.58 KB, patch)
2011-03-15 16:59 EDT, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (13.32 KB, patch)
2011-03-15 16:59 EDT, Blaise Doughan CLA
no flags Details | Diff
MOXy - Test Cases (55.59 KB, patch)
2011-03-17 13:45 EDT, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (14.14 KB, patch)
2011-03-17 13:45 EDT, Blaise Doughan CLA
no flags Details | Diff
MOXy - Test Cases (107.51 KB, patch)
2011-03-18 15:38 EDT, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (16.12 KB, patch)
2011-03-18 15:38 EDT, Blaise Doughan CLA
no flags Details | Diff
MOXy - Fix (8.41 KB, patch)
2011-03-18 15:38 EDT, Blaise Doughan CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Blaise Doughan CLA 2011-03-10 16:01:11 EST
This extension will allow the following XML document:

<?xml version="1.0" encoding="UTF-8"?>
<customer>
   <name type="FIRST">Jane</name>
   <name type="LAST">Doe</name>
   <address type="BILLING"/>
   <address type="SHIPPING"/>
</customer>


To be mapped to the following class:

package conditional;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.eclipse.persistence.oxm.annotations.XmlPath;

@XmlRootElement
@XmlType(propOrder={"firstName", "lastName", "billingAddress", "shippingAddress"})
@XmlAccessorType(XmlAccessType.FIELD)
public class Customer {

    @XmlPath("name[@type=FIRST]/text()")
    private String firstName;

    @XmlPath("name[@type=LAST]/text()")
    private String lastName;

    @XmlPath("address[@type=BILLING]")
    private Address billingAddress;

    @XmlPath("address[@type=SHIPPING]")
    private Address shippingAddress;

}

This is through adding support for predicates (the part between the square brackets) to MOXy's XPath based mapping.
Comment 1 Blaise Doughan CLA 2011-03-10 16:09:39 EST
Created attachment 190928 [details]
Core - Fix
Comment 2 Blaise Doughan CLA 2011-03-10 16:42:59 EST
Created attachment 190934 [details]
Core - Fix
Comment 3 Blaise Doughan CLA 2011-03-11 11:41:17 EST
Created attachment 191001 [details]
Core - Fix

Updated to include support for namespaces.
Comment 4 Blaise Doughan CLA 2011-03-14 12:55:29 EDT
Created attachment 191149 [details]
MOXy - Test Cases
Comment 5 Blaise Doughan CLA 2011-03-14 12:55:46 EDT
Created attachment 191150 [details]
Core - Fix
Comment 6 Blaise Doughan CLA 2011-03-14 16:45:54 EDT
Created attachment 191167 [details]
MOXy - Test Cases
Comment 7 Blaise Doughan CLA 2011-03-14 16:46:11 EDT
Created attachment 191168 [details]
Core - Fix
Comment 8 Blaise Doughan CLA 2011-03-15 16:59:35 EDT
Created attachment 191249 [details]
MOXy - Test Cases
Comment 9 Blaise Doughan CLA 2011-03-15 16:59:53 EDT
Created attachment 191250 [details]
Core - Fix
Comment 10 Blaise Doughan CLA 2011-03-17 13:45:09 EDT
Created attachment 191449 [details]
MOXy - Test Cases
Comment 11 Blaise Doughan CLA 2011-03-17 13:45:26 EDT
Created attachment 191450 [details]
Core - Fix
Comment 12 Blaise Doughan CLA 2011-03-18 15:38:22 EDT
Created attachment 191545 [details]
MOXy - Test Cases
Comment 13 Blaise Doughan CLA 2011-03-18 15:38:45 EDT
Created attachment 191546 [details]
Core - Fix
Comment 14 Blaise Doughan CLA 2011-03-18 15:38:59 EDT
Created attachment 191547 [details]
MOXy - Fix
Comment 15 Blaise Doughan CLA 2011-03-18 15:58:48 EDT
CORE CHANGES

XPathPredicate
- New class.  This class represents the [@foo='bar] portion of the XPath.  It has two properties, one to store the XPath portion and the other to hold the value.

XPathFragment
- Now can hold onto an XPathPredicate.

XMLField
- Has code to cause the XPathPredicate to be initialized.

*NodeValue
- Causes the predicate to be written when appropriate.

MarshalRecord
- Added a new method predicateAttribute which is responsible for writing the predicate attribute if one was specified.

UnmarshalRecord
- Now leverages the predicate if one is available.  This is done the same way as for positional nodes.

---

MOXy CHANGES

AnnotationsProcessor
- Added JoinNode and JoinNodes to the list of annotations that should be looked for to determine if a property has been mapped.
- Fixed an "is attribute" check.

MappingsGenerator
- Fixed an issue where the schema type was not being set to QName if the mapping was configured with @XmlPath.
Comment 16 Blaise Doughan CLA 2011-03-21 10:09:10 EDT
Fix checked into trunk at rev:  9140

Code reviewed by:  Matt MacIvor
Comment 17 Eclipse Webmaster CLA 2022-06-09 10:32:37 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink