Community
Participate
Working Groups
Given the following model, a namespace is not being returned as expected from the JAXBIntrospector call: --- package-info @javax.xml.bind.annotation.XmlSchema(namespace = "http://fish.com/example", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.example; --- ExampleElement package org.example; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for anonymous complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * <element name="child" type="{http://www.w3.org/2001/XMLSchema}string"/> * </sequence> * </restriction> * </complexContent> * </complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "child" }) @XmlRootElement(name = "exampleElement", namespace="http://fish.com/example") public class ExampleElement { @XmlElement(required = true) protected String child; /** * Gets the value of the child property. * * @return * possible object is * {@link String } * */ public String getChild() { return child; } /** * Sets the value of the child property. * * @param value * allowed object is * {@link String } * */ public void setChild(String value) { this.child = value; } } --- Demo package org.example; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBIntrospector; public class Demo { public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(ExampleElement.class); System.out.println(jc.getClass()); JAXBIntrospector ji = jc.createJAXBIntrospector(); ExampleElement ee = new ExampleElement(); System.out.println(ji.getElementName(ee)); } }
Created attachment 205937 [details] MOXy - Fix
Created attachment 205993 [details] New Test Case
Fixed in 2.3 and 2.4. Change to JAXBIntrospector getElementName to use the existing XPathFragment from the descriptor's root element field.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink