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

  • Home
  • SEARCH
  • 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 6137199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:41:46+00:00 2026-05-23T17:41:46+00:00

I have this schema and i’m using JAXB to generate java stub files. <?xml

  • 0

I have this schema and i’m using JAXB to generate java stub files.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:c="http://www.a.com/f/models/types/common"
    targetNamespace="http://www.a.com/f/models/types/common"
    elementFormDefault="qualified">

    <xs:complexType name="constants">
        <xs:sequence>
            <xs:element name="constant" type="c:constant" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="constant">
        <xs:sequence>
            <xs:element name="reference" type="c:reference"/>
        </xs:sequence>
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="type" use="required" type="c:data-type"/>
    </xs:complexType>

The default java package name is ‘com.a.f.models.types.common’

I also have existing interfaces for ‘Constants’ and ‘Constant’ defined in package ‘com.a.f.model.common’ which
i want the generated classes to use. I’m using the jaxb binding file to ensure the generated java classes implement
the required interfaces

<jxb:bindings schemaLocation="./commonmodel.xsd" node="/xs:schema">
    <jxb:bindings node="xs:complexType[@name='constants']">
        <jxb:class/>
        <inheritance:implements>com.a.f.model.common.Constants</inheritance:implements> 
    </jxb:bindings>

The generated class below does implement the correct interface

package com.a.f.models.types.common;
..
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "constants", propOrder = {
    "constant"
})
public class Constants
    implements com.a.f.model.common.Constants
{

    @XmlElement(required = true)
    protected List<Constant> constant;

    public List<Constant> getConstant() {

But the return type of the List<> getConstant() method is not correct. I need this to be

public List<com.a.f.model.common.Constant> getConstant() {

Is there away to do this via the jaxb binding file?

  • 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-23T17:41:46+00:00Added an answer on May 23, 2026 at 5:41 pm

    I worked around this by using java Generics to make the existing interfaces more flexible in their return type

    package com.a.f.m.common;
    
    import java.util.List;
    
    public interface Constants {
    
        public List<? extends Constant> getConstant();
    }
    

    Since the JAXB generated class Constant does implement the existing interface Constant, the return type on the method is allowed. It doesn’t seem possible to use the JAXB bindings file to declare the return type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this xml document (and no I didn't make up this schema). <?xml
I have xsd file. I want to generate my entity model from this schema
I have this schema: http://img602.imageshack.us/img602/6978/schemac.png I want to insert an Order with OrderItems into
i have this mysql schema: comments: ----------------------------- |id|pageid|userid| members: ----------------------------- |username|userid| sometimes the userid
I have this tables in my mysql schema: posts: --------------------------------------------- id|type | userid |
I have a table with this schema: DeviceID int FloorID int RoomID int DateRecorded
Hey i have a simple ASP.NET application Table with this schema: id | Owner
I am trying to merge 2 databases with the same schema together, and this
rake db:schema:dump rake db:test:prepare All use the following generated schema.rb: t.column cost_per_license, :decimal, :limit
I have some common types which are defined in an xsd file which is

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.