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 914801
In Process

The Archive Base Latest Questions

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

In my schema I have some types that simply extend a simple XSD type

  • 0

In my schema I have some types that simply extend a simple XSD type (int or string). JAXB creates a separate java class per such type. I want to drop this intermediate class and configure JAXB to use primitives where possible (e.g. substitute CountryType with java.lang.String and DocumentType with int or lava.lang.Integer). For example, for a given XSD it would be nice to have DestinationType.setDocumentType(int) and List<String> StatesType.getCountry(). I am happy to write type-wide an adapter for that, but it looks like only conversions from primitive XML types are supported. Maybe it is possible to make per-property type conversion? Please, give any example of JAXB binding customization, that can help.

<?xml version="1.0" encoding="UTF-8"?>
<schema
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:exch="http://www.mycompany.org/exchange"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    targetNamespace="http://www.mycompany.org/exchange"
    elementFormDefault="qualified" attributeFormDefault="unqualified">

    <complexType name="countryType">
        <simpleContent>
            <extension base="string"/>
        </simpleContent>
    </complexType>

    <complexType name="statesType">
        <sequence maxOccurs="unbounded">
            <element name="country" type="exch:countryType"/>
        </sequence>
    </complexType>

    <complexType name="documentType">
        <simpleContent>
            <extension base="integer"/>
        </simpleContent>
    </complexType>

    <complexType name="destinationType">
        <sequence>
            <element name="states" type="exch:statesType" maxOccurs="1"/>
            <element name="document-type" type="exch:documentType" minOccurs="1" maxOccurs="1"/>
        </sequence>
    </complexType>
</schema>
  • 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-15T17:46:42+00:00Added an answer on May 15, 2026 at 5:46 pm

    Another possibility, can you change your schema?:

    The following schema change will generate your desired object model.

    Use:

    <simpleType name="documentType">
        <restriction base="integer"/>
    </simpleType>
    

    Instead of:

    <complexType name="documentType"> 
        <simpleContent> 
            <extension base="integer"/> 
        </simpleContent> 
    </complexType> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some Java code that validates XML against an XSD. I am using
I have found some useful info on this issue but can't quite wrap my
I have a number of tables to store different product types in my database
I am trying to implement a short converter using TinyXML that will take an
I'm trying to put together some validation code. I am trying to validate against
Variants of this question have been asked several times now here, but my question
I'm new to .NET world, yet have to use VStudio C# 2010 (.NET 4.0)
I'm implementing a small voting system on my website. I came up with three
Does anybody know where I can find documentation on how to write annotation schemas
I'm am designing my database/domain for an eCommerce application and I'm having a hard

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.