Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Unmarshalling issue when using abstract element and substitution group #797

@glassfishrobot

Description

@glassfishrobot

Given the following schema:


























And the following XML instance document:

After running xjc on the schema, the following unit test fails. Given the FruitBowl instance returned by unmarshal(), the getFruit().getValue() call should return a Fruit object of type Banana, and the getApple() call should return an Apple instance. The actual result is that the getFruit().getValue() call returns an instance of Apple, and the getApple() call returns null. It appears that JAXB incorrectly assigns the element to the substitution group specified by the schema, and ignores the entirely, whereas the schema clearly specifies that the first element in the sequence is a member of the substitution group, and the second element is an .

Unit Test:

@test
public void testFruitBowl() throws Exception

{ Unmarshaller unmarshaller = JAXBContext.newInstance("org.mitre.jaxbtest").createUnmarshaller(); FruitBowl bowl = (FruitBowl) ((JAXBElement)unmarshaller.unmarshal(ClassLoader.getSystemClassLoader().getResource("org/mitre/jaxbtest/FruitBowl.xml"))).getValue(); Apple apple = bowl.getApple(); assertNotNull(apple); // FAILS assertEquals("apple", apple.getName()); Fruit fruit = bowl.getFruit().getValue(); assertEquals("banana", fruit.getName()); }

Environment

JDK 1.6.0_23, Windows XP.

Affected Versions

[2.1.10]

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions