Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 341149 - Enhancement: Expand @XmlDescriminatorNode to support child elements
Summary: Enhancement: Expand @XmlDescriminatorNode to support child elements
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-28 14:31 EDT by Blaise Doughan CLA
Modified: 2022-06-09 10:25 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Blaise Doughan CLA 2011-03-28 14:31:57 EDT
Currently @XmlDescriminatorNode support is restricted to attribute nodes.  Support should be expanded to include child elements:

Currently Supported:
- @XmlDiscriminatorNode("@classifier")

Add Support For:
- @XmlDiscriminatorNode("classifier/text()")
- @XmlDiscriminatorNode("grouping-element/classifier/text()")
- @XmlDiscriminatorNode("grouping-element/@classifier")
Comment 1 Dmitry Katsubo CLA 2012-02-21 13:24:42 EST
Will this extension also support "node presence" check? For example, for given type:

<xs:complexType>
	<xs:sequence>
		<xs:element name="ApplicationNumber" type="xs:string" />
		<xs:element name="CountryCode" type="xs:string" minOccurs="0" />
	</xs:sequence>
</xs:complexType>

I would like to model two Java class:

@XmlRootElement(name="Application")
class BasicApplication {
	@XmlElement(name = "ApplicationNumber", required = true)
	String applicationNumber;
}

and

@XmlRootElement(name="Application")
@XmlDiscriminatorNode("CountryCode")
class Application extends BasicApplication  {
	@XmlElement(name = "CountryCode")
	String countryCode;
}

and create "Application" instance if "<CountryCode>...</CountryCode>" is present.
Comment 2 Tom Pasierb CLA 2012-03-04 16:39:52 EST
Any chance of having the @XmlDiscriminatorNode value be an arbitrary xpath?

I have a legacy XML that I would like to map:

<MESSAGE>
  <HEADER>
    <TYPE></TYPE>
  </HEADER>
  <DATA>
    ...
  </DATA>
</MESSAGE>

Basically there are no types in the XML but the contents of the MESSAGE/DATA element are dependent on the value of MESSAGE/HEADER/TYPE. The DATA element is itself typed but there are no type indicators on it as immediate children (attributes or elements).

I'd like to either:
- type the whole Message based on the MESSAGE/HEADER/TYPE - concrete values in this element correspond to whole message types, one would have to be able to specify xpath expressions operating deeper than one level down, or
- type the DATA element based on existence of child elements with certain local names - I guess this could be done using an xpath expression like boolean(/CHILD).
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:25:09 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink