Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6886961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:49:32+00:00 2026-05-27T05:49:32+00:00

I have a JAXB schema where one class contains a list of another class.

  • 0

I have a JAXB schema where one class contains a list of another class. The schema is given below.

But whenever I create the java classes from this schema , the method is not using generics so I have to use the casts just like pre java 5 way.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:common="glodas.research">
    <xs:import namespace="glodas.research" schemaLocation="../common.xsd" />

    <!--  Dashboard Level -->    
    <xs:complexType name="DashboardStatType">
        <xs:complexContent>
            <xs:extension base="common:IndustryRegionType">
                <xs:sequence> 
                    <xs:element name="ModuleStat" type="ModuleStatType"
                            minOccurs="0" maxOccurs="unbounded" />
                    <xs:element name="BitsCount" type="BitsCount"
                            minOccurs="0" maxOccurs="unbounded"/>
                    <xs:element name="AgeLimitViolation" type="AgeLimitViolation"
                            minOccurs="0" maxOccurs="unbounded"/>
                    <xs:element name="ModuleViolation" type="ModuleViolation"
                            minOccurs="0" maxOccurs="unbounded"/>                                                        
                </xs:sequence>

                <xs:attribute name="BrCode" type="xs:string" />
                <xs:attribute name="RegionDescription" type="xs:string" />
                <xs:attribute name="AverageAgeOfBits" type="xs:int" use="required"/>
                <xs:attribute name="NewestBitDate" type="xs:date" use="required"/>
                <xs:attribute name="OldestBitDate" type="xs:date" use="required"/>
                <xs:attribute name="ChapterCount" type="xs:int" use="required"/>
                <xs:attribute name="TriggerRulesCount" type="xs:int" use="required"/>
                <xs:attribute name="TriggerEventsCount" type="xs:int" use="required"/>
                <xs:attribute name="UnpublishedCount" type="xs:int" use="required"/>

            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <!--  Module Level -->    

    <xs:complexType name="ModuleStatType">
         <xs:sequence> 
                    <xs:element name="ChapterStat" type="ChapterStatType"
                            minOccurs="0" maxOccurs="unbounded" />
                    <xs:element name="BitsCount" type="BitsCount"
                            minOccurs="0" maxOccurs="unbounded" />
                    <xs:element name="AgeLimitViolation" type="AgeLimitViolation"
                            minOccurs="0" maxOccurs="unbounded" />  
                      <xs:element name="ChapterCountViolation" type="ChapterCountViolation"
                            minOccurs="0" maxOccurs="unbounded" /> 

        </xs:sequence>
        <xs:attribute name="ModuleDescription" type="xs:string" />
        <xs:attribute name="ModuleNumber" type="xs:int" use="required" />
        <xs:attribute name="AverageAgeOfBits" type="xs:int" use="required"/>
        <xs:attribute name="NewestBitDate" type="xs:date" use="required"/>
        <xs:attribute name="OldestBitDate" type="xs:date" use="required"/>
        <xs:attribute name="TriggerRulesCount" type="xs:int" use="required"/>
        <xs:attribute name="TriggerEventsCount" type="xs:int" use="required"/>
        <xs:attribute name="UnpublishedCount" type="xs:int" use="required"/>
    </xs:complexType>

        <!--  Chapter Level -->    
     <xs:complexType name="ChapterStatType">
            <xs:sequence>
                <xs:element name="BitStat" type="BitStatType" minOccurs="0"
                    maxOccurs="unbounded" />
                <xs:element name="BitsCount" type="BitsCount"
                    minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="AgeLimitViolation" type="AgeLimitViolation"
                    minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>

                <xs:attribute name="ChapterId" type="xs:int" use="required"/>
                <xs:attribute name="ChapterTitle" type="xs:string" use="required"/>
                <xs:attribute name="AverageAgeOfBits" type="xs:int" use="required"/>
                <xs:attribute name="NewestBitDate" type="xs:date" use="required"/>
                <xs:attribute name="OldestBitDate" type="xs:date" use="required"/>
                <xs:attribute name="TriggerRulesCount" type="xs:int" use="required"/>
                <xs:attribute name="TriggerEventsCount" type="xs:int" use="required"/>
    </xs:complexType>

    <!--  Bit Level -->
    <xs:complexType name="BitStatType">
                <xs:sequence>
                <xs:element name="BitStat" type="BitStatType" minOccurs="0"
                    maxOccurs="unbounded"/>
                <xs:element name="BitAge" type="BitAge" minOccurs="0"
                    maxOccurs="unbounded"/>                 
                </xs:sequence>

                <xs:attribute name="WiId" type="xs:int" use="required"/>
                <xs:attribute name="Title" type="xs:string" use="required"/>
                <xs:attribute name="TriggerRulesCount" type="xs:int" use="required"/>
                <xs:attribute name="TriggerEventsCount" type="xs:int" use="required"/>
                <xs:attribute name="LastPublishedDate" type="xs:date" use="required"/>
    </xs:complexType>    

   <xs:complexType name="ValidationMessage">
                <xs:attribute name="Text" type="xs:string" use="required"/>
                <xs:attribute name="Severity" type="xs:int" use="optional"/>
   </xs:complexType>

    <xs:complexType name="BitAge">
        <xs:sequence>
            <xs:element name="ValidationMessage" type="ValidationMessage"
                minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="Age" type="xs:int" use="required" />
    </xs:complexType>


    <xs:complexType name="BitsCount">

        <xs:sequence>
            <xs:element name="ValidationMessage" type="ValidationMessage"
                minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="Count" type="xs:int" use="required" />
    </xs:complexType> 


    <xs:complexType name="AgeLimitViolation">
        <xs:sequence>
            <xs:element name="ValidationMessage" type="ValidationMessage"
                minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="Count" type="xs:int" use="required" />
    </xs:complexType> 

    <xs:complexType name="ChapterCountViolation">
        <xs:sequence>
            <xs:element name="ValidationMessage" type="ValidationMessage"
                minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="Count" type="xs:int" use="required" />
    </xs:complexType> 

    <xs:complexType name="ModuleViolation">
        <xs:sequence>
            <xs:element name="ValidationMessage" type="ValidationMessage"
                minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="Count" type="xs:int" use="required" />
    </xs:complexType> 

    <xs:element name="GetDashboardMonitorResponse">
        <xs:annotation>
            <xs:documentation>Response for DashboardMonitor.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element type="DashboardStatType" name="DashboardStat" minOccurs="1"
                    maxOccurs="unbounded"></xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

</xs:schema>

… The method is generated like this

    java.util.List getBitAge();

I want the java method to be generated like this

java.util.List<BitAge> getBitAge();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:49:32+00:00Added an answer on May 27, 2026 at 5:49 am

    Can you provide more details about your XML schema? I have attempted to reproduce you issue with the following

    nov30.xsd

    I made a smaill change to the XML schema you provided since I do not have the source for common.xsd:

    <!--xs:import namespace="glodas.research" schemaLocation="../common.xsd" / -->
    
    <!--  Dashboard Level -->    
    <xs:complexType name="DashboardStatType">
        <!--xs:complexContent>
            <xs:extension base="common:IndustryRegionType"-->
                <xs:sequence> 
                    <xs:element name="ModuleStat" type="ModuleStatType"
                            minOccurs="0" maxOccurs="unbounded" />
                    <xs:element name="BitsCount" type="BitsCount"
                            minOccurs="0" maxOccurs="unbounded"/>
                    <xs:element name="AgeLimitViolation" type="AgeLimitViolation"
                            minOccurs="0" maxOccurs="unbounded"/>
                    <xs:element name="ModuleViolation" type="ModuleViolation"
                            minOccurs="0" maxOccurs="unbounded"/>                                                        
                </xs:sequence>
    
                <xs:attribute name="BrCode" type="xs:string" />
                <xs:attribute name="RegionDescription" type="xs:string" />
                <xs:attribute name="AverageAgeOfBits" type="xs:int" use="required"/>
                <xs:attribute name="NewestBitDate" type="xs:date" use="required"/>
                <xs:attribute name="OldestBitDate" type="xs:date" use="required"/>
                <xs:attribute name="ChapterCount" type="xs:int" use="required"/>
                <xs:attribute name="TriggerRulesCount" type="xs:int" use="required"/>
                <xs:attribute name="TriggerEventsCount" type="xs:int" use="required"/>
                <xs:attribute name="UnpublishedCount" type="xs:int" use="required"/>
    
            <!-- /xs:extension>
        </xs:complexContent -->
    </xs:complexType>
    

    XJC Call

    xjc -d out nov30.xsd
    

    BitStatType

    The resulting list property still uses generics as expected:

    //
    // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 
    // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
    // Any modifications to this file will be lost upon recompilation of the source schema. 
    // Generated on: 2011.11.30 at 11:38:04 AM EST 
    //
    
    
    package generated;
    
    import java.util.ArrayList;
    import java.util.List;
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlAttribute;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlSchemaType;
    import javax.xml.bind.annotation.XmlType;
    import javax.xml.datatype.XMLGregorianCalendar;
    
    
    /**
     * <p>Java class for BitStatType complex type.
     * 
     * <p>The following schema fragment specifies the expected content contained within this class.
     * 
     * <pre>
     * &lt;complexType name="BitStatType">
     *   &lt;complexContent>
     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       &lt;sequence>
     *         &lt;element name="BitStat" type="{}BitStatType" maxOccurs="unbounded" minOccurs="0"/>
     *         &lt;element name="BitAge" type="{}BitAge" maxOccurs="unbounded" minOccurs="0"/>
     *       &lt;/sequence>
     *       &lt;attribute name="WiId" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
     *       &lt;attribute name="Title" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
     *       &lt;attribute name="TriggerRulesCount" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
     *       &lt;attribute name="TriggerEventsCount" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
     *       &lt;attribute name="LastPublishedDate" use="required" type="{http://www.w3.org/2001/XMLSchema}date" />
     *     &lt;/restriction>
     *   &lt;/complexContent>
     * &lt;/complexType>
     * </pre>
     * 
     * 
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "BitStatType", propOrder = {
        "bitStat",
        "bitAge"
    })
    public class BitStatType {
    
        @XmlElement(name = "BitStat")
        protected List<BitStatType> bitStat;
        @XmlElement(name = "BitAge")
        protected List<BitAge> bitAge;
        @XmlAttribute(name = "WiId", required = true)
        protected int wiId;
        @XmlAttribute(name = "Title", required = true)
        protected String title;
        @XmlAttribute(name = "TriggerRulesCount", required = true)
        protected int triggerRulesCount;
        @XmlAttribute(name = "TriggerEventsCount", required = true)
        protected int triggerEventsCount;
        @XmlAttribute(name = "LastPublishedDate", required = true)
        @XmlSchemaType(name = "date")
        protected XMLGregorianCalendar lastPublishedDate;
    
        /**
         * Gets the value of the bitStat property.
         * 
         * <p>
         * This accessor method returns a reference to the live list,
         * not a snapshot. Therefore any modification you make to the
         * returned list will be present inside the JAXB object.
         * This is why there is not a <CODE>set</CODE> method for the bitStat property.
         * 
         * <p>
         * For example, to add a new item, do as follows:
         * <pre>
         *    getBitStat().add(newItem);
         * </pre>
         * 
         * 
         * <p>
         * Objects of the following type(s) are allowed in the list
         * {@link BitStatType }
         * 
         * 
         */
        public List<BitStatType> getBitStat() {
            if (bitStat == null) {
                bitStat = new ArrayList<BitStatType>();
            }
            return this.bitStat;
        }
    
        /**
         * Gets the value of the bitAge property.
         * 
         * <p>
         * This accessor method returns a reference to the live list,
         * not a snapshot. Therefore any modification you make to the
         * returned list will be present inside the JAXB object.
         * This is why there is not a <CODE>set</CODE> method for the bitAge property.
         * 
         * <p>
         * For example, to add a new item, do as follows:
         * <pre>
         *    getBitAge().add(newItem);
         * </pre>
         * 
         * 
         * <p>
         * Objects of the following type(s) are allowed in the list
         * {@link BitAge }
         * 
         * 
         */
        public List<BitAge> getBitAge() {
            if (bitAge == null) {
                bitAge = new ArrayList<BitAge>();
            }
            return this.bitAge;
        }
    
        /**
         * Gets the value of the wiId property.
         * 
         */
        public int getWiId() {
            return wiId;
        }
    
        /**
         * Sets the value of the wiId property.
         * 
         */
        public void setWiId(int value) {
            this.wiId = value;
        }
    
        /**
         * Gets the value of the title property.
         * 
         * @return
         *     possible object is
         *     {@link String }
         *     
         */
        public String getTitle() {
            return title;
        }
    
        /**
         * Sets the value of the title property.
         * 
         * @param value
         *     allowed object is
         *     {@link String }
         *     
         */
        public void setTitle(String value) {
            this.title = value;
        }
    
        /**
         * Gets the value of the triggerRulesCount property.
         * 
         */
        public int getTriggerRulesCount() {
            return triggerRulesCount;
        }
    
        /**
         * Sets the value of the triggerRulesCount property.
         * 
         */
        public void setTriggerRulesCount(int value) {
            this.triggerRulesCount = value;
        }
    
        /**
         * Gets the value of the triggerEventsCount property.
         * 
         */
        public int getTriggerEventsCount() {
            return triggerEventsCount;
        }
    
        /**
         * Sets the value of the triggerEventsCount property.
         * 
         */
        public void setTriggerEventsCount(int value) {
            this.triggerEventsCount = value;
        }
    
        /**
         * Gets the value of the lastPublishedDate property.
         * 
         * @return
         *     possible object is
         *     {@link XMLGregorianCalendar }
         *     
         */
        public XMLGregorianCalendar getLastPublishedDate() {
            return lastPublishedDate;
        }
    
        /**
         * Sets the value of the lastPublishedDate property.
         * 
         * @param value
         *     allowed object is
         *     {@link XMLGregorianCalendar }
         *     
         */
        public void setLastPublishedDate(XMLGregorianCalendar value) {
            this.lastPublishedDate = value;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm want to generate java classes from a schema using jaxb, but I am
I have used JAXB to create a class for the following schema (used in
I have a XML schema that I will need to create Java classes for.
Assuming I have a schema that describes a root element class Root that contains
I have this schema and i'm using JAXB to generate java stub files. <?xml
I'm using JAXB(xjc version 2.2.4-2) to generate Java classes from a XML Schema. The
I have a number of XML schema that use JAXB (Java Architecture for XML
I have the following java class with the JAXB @XMLRootElement annotation @XmlRootElement(name=ClientData) public class
We have this JAXB annotation: @XmlElement(name = Strategy, required = true) protected List<Strategy> strategy;
I have one module where I have my XSD schemas, where one schema can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.