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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:13:14+00:00 2026-06-11T20:13:14+00:00

We have an xsd schema with a declaration like this: <xsd:simpleType name=customId> <xsd:annotation> <xsd:appinfo>

  • 0

We have an xsd schema with a declaration like this:

<xsd:simpleType name="customId">
    <xsd:annotation>
        <xsd:appinfo>
            <jaxb:javaType name="com.company.identifiers.CustomId" parseMethod="fromString" printMethod="toString"/>
        </xsd:appinfo>
    </xsd:annotation>
    <xsd:restriction base="xsd:int" />
</xsd:simpleType>

Then, I want to have a list of this type in a generated Java class:

<xsd:complexType name="SomeMessage">
    ...
<xsd:attribute name="customIds" use="optional">
        <xsd:simpleType>
            <xsd:list itemType="customId" />
        </xsd:simpleType>
</xsd:attribute>
    ...
</xsd:complexType>

But the field customIds, for some reason, is generated as List<String>.

I guess, xsd:sequence could be used instead of xsd:list, but SomeMessage already has an xsd:choice, and as far as I get, it is illegal to have xsd:sequence in the same declaration.

Thanks!

  • 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-06-11T20:13:15+00:00Added an answer on June 11, 2026 at 8:13 pm

    Code generated using NetBeans 7.1.2, running on Java 1.7.0_02.

    If you want to map simple types to Java classes, one way to do is to globally set mapSimpleTypeDef="true"

    <xsd:annotation>
        <xsd:appinfo>
            <jaxb:globalBindings mapSimpleTypeDef="true"/>
        </xsd:appinfo>
    </xsd:annotation>
    

    Generated code:

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "SomeMessage")
    public class SomeMessage {
    
        @XmlAttribute(name = "customIds")
        protected List<CustomId> customIds;
    
        /**
         * Gets the value of the customIds property.
         * 
         * <p>
         * Objects of the following type(s) are allowed in the list
         * {@link CustomId }
         * 
         * 
         */
        public List<CustomId> getCustomIds() {
            if (customIds == null) {
                customIds = new ArrayList<CustomId>();
            }
            return this.customIds;
        }
    
    }
    

    If you want to refer your pre-existing CustomId class, then the following works in my case:

    <xsd:simpleType name="customId">
        <xsd:restriction base="xsd:int"/>
    </xsd:simpleType>
    <xsd:complexType name="SomeMessage">
        <xsd:attribute name="customIds" use="optional">
            <xsd:simpleType>
                <xsd:annotation>
                    <xsd:appinfo>
                        <jaxb:javaType name="java.util.List&lt;com.company.identifiers.CustomId>" parseMethod="Class1.fromString" printMethod="Class1.toString"/>
                    </xsd:appinfo>
                </xsd:annotation>
                <xsd:list itemType="customId"/>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:complexType>
    

    You’ll get the following:

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "SomeMessage")
    public class SomeMessage {
    
        @XmlAttribute(name = "customIds")
        @XmlJavaTypeAdapter(Adapter1 .class)
        protected List<CustomId> customIds;
    
        /**
         * Gets the value of the customIds property.
         * 
         * @return
         *     possible object is
         *     {@link String }
         *     
         */
        public List<CustomId> getCustomIds() {
            return customIds;
        }
    
        /**
         * Sets the value of the customIds property.
         * 
         * @param value
         *     allowed object is
         *     {@link String }
         *     
         */
        public void setCustomIds(List<CustomId> value) {
            this.customIds = value;
        }
    
    }
    

    And the generated Adapter1:

    public class Adapter1
        extends XmlAdapter<String, List<CustomId>>
    {
    
    
        public List<CustomId> unmarshal(String value) {
            return (Class1.fromString(value));
        }
    
        public String marshal(List<CustomId> value) {
            return (Class1.toString(value));
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this XSD XML (happens to be a WSDL) file: <definitions targetNamespace=http://soft.com/ name=LoggingWebService
I have this XSD element defined: <xsd:element name=CU_FIRST_NAME> <xsd:annotation> <xsd:documentation> The first name of
I have this big doubt. When ever i use base64Binary in an .xsd schema
Suppose I have some schema: <xsd:schema ...> <xsd:element name=foo> <xsd:complexType> <xsd:sequence> <xsd:element name=fooElement type=xs:string
I have xsd file. I want to generate my entity model from this schema
I have following xsd: <?xml version=1.0 encoding=UTF-8?> <xsd:schema targetNamespace=http://www.something.com/GetWrapRequest elementFormDefault=qualified attributeFormDefault=qualified version=1.0 xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:gwreq=http://www.something.com/GetWrapRequest>
Hi I have xsd schema with base64Binary. when this plugin genereted this elemen looks
I have wsdl that includes many xsds <wsdl:types> <xsd:schema elementFormDefault=qualified targetNamespace=Name/Space> <xsd:include schemaLocation=role.xsd/> <xsd:include
I have the following XSD file: <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://www.wvf.com/schemas' xmlns='http://www.wvf.com/schemas' xmlns:acmewvf='http://www.wvf.com/schemas'> <xs:element name='loft'> </xs:element>
I have xsd schema file which I can't change. Here is an excerpt that

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.