Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312117 - Using substitution name for an element causes duplicate elements in marshalled XML
Summary: Using substitution name for an element causes duplicate elements in marshalle...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-07 15:19 EDT by Rick Barkhouse CLA
Modified: 2022-06-09 10:20 EDT (History)
0 users

See Also:


Attachments
Patch (14.39 KB, patch)
2010-05-07 16:56 EDT, Rick Barkhouse CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rick Barkhouse CLA 2010-05-07 15:19:07 EDT
Considering the following schema:

...
    <xs:element name="name" type="xs:string"/>
    <xs:element name="nom" substitutionGroup="myns:name"/>

    <xs:complexType name="person">
        <xs:sequence>
            <xs:element ref="myns:name"/>
        </xs:sequence>
    </xs:complexType>

    <xs:element name="person" type="myns:person"/>
    <xs:element name="personne" substitutionGroup="myns:person"/>
...

Taking this schema and generating EclipseLink mappings, if we set the JAXBElement for "name" to have a QName of "nom", then you will see duplicate elements written to XML, for both the original as well as the substituted name:

<?xml version="1.0" encoding="UTF-8"?>
<ns0:person xmlns:ns0="myNamespace">
   <ns0:name>Bob Smith</ns0:name>
   <ns0:nom>Bob Smith</ns0:nom>
</ns0:person>
Comment 1 Rick Barkhouse CLA 2010-05-07 16:56:09 EDT
Created attachment 167577 [details]
Patch

Code fix + new test case
Comment 2 Rick Barkhouse CLA 2010-05-07 17:12:55 EDT
Fixed and checked in, reviewed by bdoughan.
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:20:59 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink