Geen cache-versie.

Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code LNG204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.
javax.xml.bind.annotation

Annotation Type XmlRootElement


  • @Retention(value=RUNTIME)
    @Target(value=TYPE)
    public @interface XmlRootElement
    Maps a class or an enum type to an XML element.

    Usage

    The @XmlRootElement annotation can be used with the following program elements:

    • a top level class
    • an enum type

    See "Package Specification" in javax.xml.bind.package javadoc for additional common information.

    When a top level class or an enum type is annotated with the @XmlRootElement annotation, then its value is represented as XML element in an XML document.

    This annotation can be used with the following annotations: XmlType, XmlEnum, XmlAccessorType, XmlAccessorOrder.

    Example 1: Associate an element with XML Schema type

         // Example: Code fragment
         @XmlRootElement
         class Point {
            int x;
            int y;
            Point(int _x,int _y) {x=_x;y=_y;}
         }
     
         //Example: Code fragment corresponding to XML output
         marshal( new Point(3,5), System.out);
     
         <!-- Example: XML output -->
         <point>
           <x> 3 
           <y> 5 
         </point>
     
    The annotation causes an global element declaration to be produced in the schema. The global element declaration is associated with the XML schema type to which the class is mapped.
         <!-- Example: XML schema definition -->
         <xs:element name="point" type="point"/>
         <xs:complexType name="point">
           <xs:sequence>
             <xs:element name="x" type="xs:int"/>
             <xs:element name="y" type="xs:int"/>
           </xs:sequence>
         </xs:complexType>
     

    Example 2: Orthogonality to type inheritance

    An element declaration annotated on a type is not inherited by its derived types. The following example shows this.

         // Example: Code fragment
         @XmlRootElement
         class Point3D extends Point {
             int z;
             Point3D(int _x,int _y,int _z) {super(_x,_y);z=_z;}
         }
    
         //Example: Code fragment corresponding to XML output *
         marshal( new Point3D(3,5,0), System.out );
    
         <!-- Example: XML output -->
         <!-- The element name is point3D not point -->
         <point3D>
           <x>3</x>
           <y>5</y>
           <z>0</z>
         </point3D>
    
         <!-- Example: XML schema definition -->
         <xs:element name="point3D" type="point3D"/>
         <xs:complexType name="point3D">
           <xs:complexContent>
             <xs:extension base="point">
               <xs:sequence>
                 <xs:element name="z" type="xs:int"/>
               </xs:sequence>
             </xs:extension>
           </xs:complexContent>
         </xs:complexType>
     
    Example 3: Associate a global element with XML Schema type to which the class is mapped.
         //Example: Code fragment
         @XmlRootElement(name="PriceElement")
         public class USPrice {
             @XmlElement
             public java.math.BigDecimal price;
         }
    
         <!-- Example: XML schema definition -->
         <xs:element name="PriceElement" type="USPrice"/>
         <xs:complexType name="USPrice">
           <xs:sequence>
             <xs:element name="price" type="xs:decimal"/>
           </sequence>
         </xs:complexType>
     
    Since:
    JAXB2.0
    • Element Detail

      • namespace

        public abstract String namespace
        namespace name of the XML element.

        If the value is "##default", then the XML namespace name is derived from the package of the class ( XmlSchema ). If the package is unnamed, then the XML namespace is the default empty namespace.

        Default:
        "##default"
      • name

        public abstract String name
        local name of the XML element.

        If the value is "##default", then the name is derived from the class name.

        Default:
        "##default"

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/xml/bind/annotation/xmlrootelement.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut