Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB XmlAnyElement set namespace attribute

I have a simple Java class I am annotating with JAXB:

class Foo {
   @XmlAnyElement(lax=true)
   List<Object> any;
}

Which produces the following schema:

<xs:complexType name="foo">
  <xs:sequence>
    <xs:any processContents="lax" maxOccurs="unbounded"/>
  </xs:sequence>
</xs:complexType>

Is there any way to set the namespace attribute for the <any> element, so that it generates like:

<xs:any namespace="##targetNamespace" processContents="lax" maxOccurs="unbounded"/>
like image 307
schmimd04 Avatar asked May 22 '12 20:05

schmimd04


1 Answers

insert a package-info.java file into your foo class package with contents like :

@javax.xml.bind.annotation.XmlSchema(namespace = "urn:foo:v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package java.ns.foo;
like image 129
fla Avatar answered Sep 28 '22 06:09

fla