I have an object that I want to marshall but the schema does not have the @XmlRootElement annotation.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
public static class Foo
{
@XmlAttribute(name = "test1")
public final static String TEST_1 = "Foo";
@XmlElement(name = "Element1", required = true)
protected String element1;
@XmlElement(name = "Element2", required = true)
protected String element2;
}
I marshalled the object by specifying a JaxBElement while marshalling
QName qName = new QName("", "Foo");
jaxb2Marshaller.marshal(new JAXBElement(qName, Foo.class, fooObj), new StreamResult(baos));
This results in the following XML after marshalling
<Foo xmlns:ns2="http://Foo/bar" test1="Foo">
<ns2:Element1>000000013</ns2:Element1>
<ns2:Element2>12345678900874357</ns2:Element2>
</Foo>
For my usecase I would like to marhsall this object without the ns2 prefix so that the XML would look like
<Foo xmlns="http://Foo/bar" test1="Foo">
<Element1>000000013</Element1>
<Element2>12345678900874357</Element2>
</Foo>
How can I marshall this object without the prefix?
Thanks in Advance.