Annotation Interface Xml
Can be used in the following locations:
- Marshalled classes/methods/fields/packages.
- @Rest -annotated classes and- @RestOp -annotated methods when an- on()value is specified.
Can be used for the following:
- Override the child element name on the XML representation of collection or array properties.
- Specify the XML namespace on a package, class, or method.
- Override the XML format on a POJO.
See Also:
- 
Optional Element SummaryOptional ElementsModifier and TypeOptional ElementDescriptionSets the name of the XML child elements for bean properties of type collection and array.String[]Optional description for the exposed API.TheXmlFormatto use for serializing this object type.Sets the namespace URI of this property or class.String[]Dynamically apply this annotation to the specified classes/methods/fields.Class<?>[]Dynamically apply this annotation to the specified classes.Sets the XML prefix of this property or class.
- 
Element Details- 
childNameSets the name of the XML child elements for bean properties of type collection and array.Applies only to collection and array bean properties. Example:public class MyBean {@Xml (childName="child" }public String[]children = {"foo" ,"bar" }; }Without the @Xml annotation, serializing this bean as XML would have produced the following...<object> <children> <string> foo</string> <string> bar</string> </children> </object> With the annotations, serializing this bean as XML produces the following... <object> <children> <child> foo</child> <child> bar</child> </children> </object> - Returns:
- The annotation value.
 - Default:
- ""
 
- 
descriptionOptional description for the exposed API.- Returns:
- The annotation value.
- Since:
- 9.2.0
 - Default:
- {}
 
- 
formatTheXmlFormatto use for serializing this object type.Example:public class MyBean {// Normally, bean properties would be rendered as child elements of the bean element. // Override so that it's rendered as a "f1='123'" attribute on the bean element instead. @Xml (format=XmlFormat.ATTR }public int f1 = 123;// Normally, bean URL properties would be rendered as XML attributes on the bean element. // Override so that it's rendered as an <href>http://foo</href> child element instead. @Beanp (uri=true )@Xml (format=XmlFormat.ELEMENT }public URLhref =new URL("http://foo" );// Normally, collection properties would be grouped under a single <children> child element on the bean element. // Override so that entries are directly children of the bean element with each entry having an element name of <child>. @Xml (format=XmlFormat.COLLAPSED , childName="child" }public String[]children ="foo" ,"bar" }; }Without the @Xml annotations, serializing this bean as XML would have produced the following...<object href ='http://foo' > <f1> 123</f1> <children> <string> foo</string> <string> bar</string> </children> </object> With the annotations, serializing this bean as XML produces the following... <object f1 ='123' > <href> http://foo</href> <child> foo</child> <child> bar</child> </object> - Returns:
- The annotation value.
 - Default:
- DEFAULT
 
- 
namespaceSets the namespace URI of this property or class.Must be matched with a prefix()annotation on this object, a parent object, or a@XmlNswith the same name through the@XmlSchema(xmlNs)annotation on the package.- Returns:
- The annotation value.
 - Default:
- ""
 
- 
onDynamically apply this annotation to the specified classes/methods/fields.Used in conjunction with BeanContext.Builder.applyAnnotations(Class...)to dynamically apply an annotation to an existing class/method/field. It is ignored when the annotation is applied directly to classes/methods/fields.Valid patterns:- Classes:
      - Fully qualified:
            - "com.foo.MyClass" 
 
- Fully qualified inner class:
            - "com.foo.MyClass$Inner1$Inner2" 
 
- Simple:
            - "MyClass" 
 
- Simple inner:
            - "MyClass$Inner1$Inner2" 
- "Inner1$Inner2" 
- "Inner2" 
 
 
- Fully qualified:
            
- Methods:
      - Fully qualified with args:
            - "com.foo.MyClass.myMethod(String,int)" 
- "com.foo.MyClass.myMethod(java.lang.String,int)" 
- "com.foo.MyClass.myMethod()" 
 
- Fully qualified:
            - "com.foo.MyClass.myMethod" 
 
- Simple with args:
            - "MyClass.myMethod(String,int)" 
- "MyClass.myMethod(java.lang.String,int)" 
- "MyClass.myMethod()" 
 
- Simple:
            - "MyClass.myMethod" 
 
- Simple inner class:
            - "MyClass$Inner1$Inner2.myMethod" 
- "Inner1$Inner2.myMethod" 
- "Inner2.myMethod" 
 
 
- Fully qualified with args:
            
- Fields:
      - Fully qualified:
            - "com.foo.MyClass.myField" 
 
- Simple:
            - "MyClass.myField" 
 
- Simple inner class:
            - "MyClass$Inner1$Inner2.myField" 
- "Inner1$Inner2.myField" 
- "Inner2.myField" 
 
 
- Fully qualified:
            
- A comma-delimited list of anything on this list.
 See Also:- Returns:
- The annotation value.
 - Default:
- {}
 
- Classes:
      
- 
onClassDynamically apply this annotation to the specified classes.Identical to on()except allows you to specify class objects instead of a strings.See Also:- Returns:
- The annotation value.
 - Default:
- {}
 
- 
prefixSets the XML prefix of this property or class.- 
      When applied to a ElementType.TYPE, namespace is applied to all properties in the class, and all subclasses of the class.
- 
      When applied to bean properties on ElementType.METHODandElementType.FIELD, applies to the bean property.
 Must either be matched to a namespace()annotation on the same object, parent object, or a@XmlNswith the same name through the@XmlSchema(xmlNs)annotation on the package.- Returns:
- The annotation value.
 - Default:
- ""
 
- 
      When applied to a 
 
-