Annotation Type XmlElementDecl
-
@Retention(RUNTIME) @Target(METHOD) public @interface XmlElementDeclMaps a factory method to an XML element.Usage
The annotation creates a mapping between an XML schema element declaration and a element factory method that returns a JAXBElement instance representing the element declaration. Typically, the element factory method is generated (and annotated) from a schema into the ObjectFactory class in a Java package that represents the binding of the element declaration's target namespace. Thus, while the annotation syntax allows @XmlElementDecl to be used on any method, semantically its use is restricted to annotation of element factory method.The usage is subject to the following constraints:
- The class containing the element factory method annotated
with @XmlElementDecl must be marked with
XmlRegistry. - The element factory method must take one parameter
assignable to
Object.
Example 1: Annotation on a factory method {@snippet : // Example: code fragment
- Since:
- 1.6, JAXB 2.0
- See Also:
XmlRegistry
- The class containing the element factory method annotated
with @XmlElementDecl must be marked with
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.Stringnamelocal name of the XML element.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.StringdefaultValueDefault value of this element.java.lang.Stringnamespacenamespace name of the XML element.java.lang.Class<?>scopescope of the mapping.java.lang.StringsubstitutionHeadNameXML local name of a substitution group's head element.java.lang.StringsubstitutionHeadNamespacenamespace name of a substitution group's head XML element.
-
-
-
Element Detail
-
name
java.lang.String name
local name of the XML element.Note to reviewers: There is no default name; since the annotation is on a factory method, it is not clear that the method name can be derived from the factory method name.
- See Also:
namespace()
-
-
-
scope
java.lang.Class<?> scope
scope of the mapping.If this is not
XmlElementDecl.GLOBAL, then this element declaration mapping is only active within the specified class.- Default:
- jakarta.xml.bind.annotation.XmlElementDecl.GLOBAL.class
-
-
-
namespace
java.lang.String namespace
namespace name of the XML element.If the value is "##default", then the value is the namespace name for the package of the class containing this factory method.
- See Also:
name()
- Default:
- "##default"
-
-
-
substitutionHeadNamespace
java.lang.String substitutionHeadNamespace
namespace name of a substitution group's head XML element.This specifies the namespace name of the XML element whose local name is specified by
substitutionHeadName().If
substitutionHeadName()is "", then this value can only be "##default". But the value is ignored since this element is not part of substitution group when the value ofsubstitutionHeadName()is "".If
substitutionHeadName()is not "" and the value is "##default", then the namespace name is the namespace name to which the package of the containing class, marked withXmlRegistry, is mapped.If
substitutionHeadName()is not "" and the value is not "##default", then the value is the namespace name.- See Also:
substitutionHeadName()
- Default:
- "##default"
-
-
-
substitutionHeadName
java.lang.String substitutionHeadName
XML local name of a substitution group's head element.If the value is "", then this element is not part of any substitution group.
- See Also:
substitutionHeadNamespace()
- Default:
- ""
-
-