Suppose we have list of objects and we want to marshal them via JAXB:
@XmlElement(name = "value")
public List<Object> getValues() {
return values;
By default this would produce following output:
<value xsi:type="xs:int" xmlns:xsi="" xmlns:xs="">123</value>
<value xsi:type="xs:boolean" xmlns:xsi="" xmlns:xs="">true</value>
<value xsi:type="xs:string" xmlns:xsi="" xmlns:xs="">Lorem ipsum</value>
Pay attention that standard schema URIs duplicated for each list item - quite inefficient if we have lot of items. This issue can be addressed with package-level annotations. Add file to the package that contains your domain classes:
@XmlSchema(xmlns = {@XmlNs(prefix = "xsi", namespaceURI = XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI),
@XmlNs(prefix = "xs", namespaceURI = XMLConstants.W3C_XML_SCHEMA_NS_URI)})
package com.jaspersoft.ji.jaxrs.query;

import javax.xml.XMLConstants;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlSchema;
Now schema URIs will be specified only once, in the root element:
<myContainerTag xmlns:xs="" xmlns:xsi="">
<value xsi:type="xs:int">123</value>
<value xsi:type="xs:boolean">true</value>
<value xsi:type="xs:string">Lorem ipsum</value>