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.

xjc generates no JAXBElement for nillable element with required attribute  #858

Closed

Description

@glassfishrobot

Taken from CXF bug:
https://issues.apache.org/jira/browse/CXF-3732

Please consider the following schema:

<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.org" targetNamespace="http://www.example.org" elementFormDefault="qualified">
  <xsd:element name="root">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="eal" nillable="true">
          <xsd:complexType>
            <xsd:simpleContent>
              <xsd:extension base="xsd:string">
<xsd:attribute name="att" type="xsd:string" use="required"/>
              </xsd:extension>
            </xsd:simpleContent>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

Running this through xjc generates a member eal of type Root.Eal in Root, not of type JAXBElement<Root.Eal>.
This makes it impossible to unmarshal a document like

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root xmlns="http://www.example.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <eal att="j" xsi:nil="true"/>
</root>

and obtain the value for attribute att in eal, since eal is null. The above XML document cannot be represented in the classes generated by xjc.

Activity

  1. glassfishrobot commented on Aug 30, 2011

    @glassfishrobot
    ContributorAuthor

    Reported by dkulp

  2. glassfishrobot commented on Aug 30, 2011

    @glassfishrobot
    ContributorAuthor

    Issue-Links:
    duplicates
    JAXB-822

  3. glassfishrobot commented on Aug 30, 2011

    @glassfishrobot
    ContributorAuthor

    Was assigned to snajper

  4. glassfishrobot commented on Nov 22, 2011

    @glassfishrobot
    ContributorAuthor

    Marked as duplicate on Tuesday, November 22nd 2011, 6:17:02 am

  5. glassfishrobot commented on Apr 24, 2017

    @glassfishrobot
    ContributorAuthor

    This issue was imported from java.net JIRA JAXB-858

  6. added this to the 2.2.5 milestone on Apr 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions