Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid @XmlElementRef : Type "class java.lang.Double" or any of its subclasses are not known to this context. #2

Open
hamza-zag opened this issue Nov 25, 2020 · 3 comments

Comments

@hamza-zag
Copy link

hamza-zag commented Nov 25, 2020

it seems that the element is generating incorrectly "@XmlElementRef" instead of "@xmlelement".

public class AllowedValuesType
    extends AbstractSWEType
    implements Serializable
{
    private final static long serialVersionUID = 1L;
    @XmlElement(type = Double.class)
    protected List<Double> value;
    @XmlElementRef(type = Double.class)
    protected List<Double> interval;
    protected BigInteger significantFigures;
......

XSD:

    <complexType name="AllowedValuesType">
        <complexContent>
            <extension base="swe:AbstractSWEType">
                <sequence>
                    <element maxOccurs="unbounded" minOccurs="0" name="value" type="double"/>
                    <element maxOccurs="unbounded" minOccurs="0" name="interval" type="swe:RealPair"/>
                    <element maxOccurs="1" minOccurs="0" name="significantFigures" type="integer"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
<simpleType name="RealPair">
		<restriction>
			<simpleType>
				<list itemType="double"/>
			</simpleType>
			<length value="2"/>
		</restriction>
	</simpleType>
@bghost4
Copy link

bghost4 commented Sep 29, 2021

I Second this issue.

@bertramn
Copy link
Collaborator

You will find that doing substitutions on simple data types is probably going to cause a lot more issues. the Java type system is much more limited than the XSD one and hence the JAXB runtime needs all these annotations to figure out how to enforce the additional rules of the XSD model with Java properties. I wrote the plugin to simplify the Java class model where the attribute field would be of a complex type with possible sub type implementations. If you can create a repeatable test failure, I can have a look what happens in the XJC compiler.

@bghost4
Copy link

bghost4 commented Sep 30, 2021

Let me see if I can throw together an example, I'm not using Double, it's a complex type, but it's giving the same subclasses are not known to this context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants