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

The Archive Base Latest Questions

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

I am trying to generate Java classes to bind xml to objects using castor.

  • 0

I am trying to generate Java classes to bind xml to objects using castor. The piece of xml that I am trying to bind is a spring xml file so i took the dtd and generated the xsd using the tools castor provided, but once I attempt to generate the source files i recieve the following error

    java.lang.IllegalArgumentException: Duplicate name found as a class member: _key

Here is the xsd file that I have generated:

    <?xml version="1.0" encoding="UTF-8"?>
        <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="generated.castor.org">
<element name="entry">
    <complexType>
        <sequence>
            <element ref="key" minOccurs="0" />
            <choice minOccurs="0">
                <element ref="bean" />
                <element ref="ref" />
                <element ref="idref" />
                <element ref="value" />
                <element ref="null" />
                <element ref="list" />
                <element ref="set" />
                <element ref="map" />
                <element ref="props" />
            </choice>
        </sequence>
        <attribute name="value-ref" type="string" />
        <attribute name="key" type="string" />
        <attribute name="value" type="string" />
        <attribute name="key-ref" type="string" />
    </complexType>
</element>
<element name="arg-type">
    <complexType mixed="true">
        <attribute name="match" type="string" />
    </complexType>
</element>
<element name="bean">
    <complexType>
        <sequence>
            <element ref="description" minOccurs="0" />
            <choice minOccurs="0" maxOccurs="unbounded">
                <element ref="meta" />
                <element ref="constructor-arg" />
                <element ref="property" />
                <element ref="lookup-method" />
                <element ref="replaced-method" />
            </choice>
        </sequence>
        <attribute name="name" type="string" />
        <attribute name="id" type="ID" />
        <attribute name="class" type="string" />
        <attribute name="singleton" default="true">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="false" />
                    <enumeration value="true" />
                </restriction>
            </simpleType>
        </attribute>
        <attribute name="factory-method" type="string" />
        <attribute name="dependency-check" default="default">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="default" />
                    <enumeration value="simple" />
                    <enumeration value="none" />
                    <enumeration value="objects" />
                    <enumeration value="all" />
                </restriction>
            </simpleType>
        </attribute>
        <attribute name="lazy-init" default="default">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="default" />
                    <enumeration value="false" />
                    <enumeration value="true" />
                </restriction>
            </simpleType>
        </attribute>
        <attribute name="autowire-candidate" default="true">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="false" />
                    <enumeration value="true" />
                </restriction>
            </simpleType>
        </attribute>
        <attribute name="init-method" type="string" />
        <attribute name="autowire" default="default">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="default" />
                    <enumeration value="no" />
                    <enumeration value="byName" />
                    <enumeration value="autodetect" />
                    <enumeration value="byType" />
                    <enumeration value="constructor" />
                </restriction>
            </simpleType>
        </attribute>
        <attribute name="destroy-method" type="string" />
        <attribute name="abstract" default="false">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="false" />
                    <enumeration value="true" />
                </restriction>
            </simpleType>
        </attribute>
        <attribute name="depends-on" type="string" />
        <attribute name="parent" type="string" />
        <attribute name="factory-bean" type="string" />
    </complexType>
</element>
<element name="prop">
    <complexType mixed="true">
        <attribute name="key" type="string" use="required" />
    </complexType>
</element>
<element name="beans">
    <complexType>
        <sequence>
            <element ref="description" minOccurs="0" />
            <choice minOccurs="0" maxOccurs="unbounded">
                <element ref="import" />
                <element ref="alias" />
                <element ref="bean" />
            </choice>
        </sequence>
        <attribute name="default-destroy-method" type="string" />
        <attribute name="default-lazy-init" default="false">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="false" />
                    <enumeration value="true" />
                </restriction>
            </simpleType>
        </attribute>
        <attribute name="default-init-method" type="string" />
        <attribute name="default-dependency-check" default="none">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="simple" />
                    <enumeration value="none" />
                    <enumeration value="objects" />
                    <enumeration value="all" />
                </restriction>
            </simpleType>
        </attribute>
        <attribute name="default-autowire" default="no">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="no" />
                    <enumeration value="byName" />
                    <enumeration value="autodetect" />
                    <enumeration value="byType" />
                    <enumeration value="constructor" />
                </restriction>
            </simpleType>
        </attribute>
        <attribute name="default-merge" default="false">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="false" />
                    <enumeration value="true" />
                </restriction>
            </simpleType>
        </attribute>
    </complexType>
</element>
<element name="props">
    <complexType>
        <sequence>
            <element ref="prop" minOccurs="0" maxOccurs="unbounded" />
        </sequence>
        <attribute name="merge" default="default">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="default" />
                    <enumeration value="false" />
                    <enumeration value="true" />
                </restriction>
            </simpleType>
        </attribute>
    </complexType>
</element>
<element name="lookup-method">
    <complexType>
        <attribute name="bean" type="string" />
        <attribute name="name" type="string" />
    </complexType>
</element>
<element name="replaced-method">
    <complexType>
        <sequence>
            <element ref="arg-type" minOccurs="0" maxOccurs="unbounded" />
        </sequence>
        <attribute name="name" type="string" />
        <attribute name="replacer" type="string" />
    </complexType>
</element>
<element name="ref">
    <complexType>
        <attribute name="bean" type="string" />
        <attribute name="local" type="IDREF" />
        <attribute name="parent" type="string" />
    </complexType>
</element>
<element name="property">
    <complexType>
        <sequence>
            <element ref="description" minOccurs="0" />
            <element ref="meta" minOccurs="0" maxOccurs="unbounded" />
            <choice minOccurs="0">
                <element ref="bean" />
                <element ref="ref" />
                <element ref="idref" />
                <element ref="value" />
                <element ref="null" />
                <element ref="list" />
                <element ref="set" />
                <element ref="map" />
                <element ref="props" />
            </choice>
        </sequence>
        <attribute name="name" type="string" use="required" />
        <attribute name="ref" type="string" />
        <attribute name="value" type="string" />
    </complexType>
</element>
<element name="import">
    <complexType>
        <attribute name="resource" type="string" use="required" />
    </complexType>
</element>
<element name="meta">
    <complexType>
        <attribute name="key" type="string" use="required" />
        <attribute name="value" type="string" use="required" />
    </complexType>
</element>
<element name="set">
    <complexType>
        <choice minOccurs="0" maxOccurs="unbounded">
            <element ref="bean" />
            <element ref="ref" />
            <element ref="idref" />
            <element ref="value" />
            <element ref="null" />
            <element ref="list" />
            <element ref="set" />
            <element ref="map" />
            <element ref="props" />
        </choice>
        <attribute name="value-type" type="string" />
        <attribute name="merge" default="default">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="default" />
                    <enumeration value="false" />
                    <enumeration value="true" />
                </restriction>
            </simpleType>
        </attribute>
    </complexType>
</element>
<element name="null">
    <complexType mixed="true" />
</element>
<element name="alias">
    <complexType>
        <attribute name="name" type="string" use="required" />
        <attribute name="alias" type="string" use="required" />
    </complexType>
</element>
<element name="value">
    <complexType mixed="true">
        <attribute name="type" type="string" />
    </complexType>
</element>
<element name="constructor-arg">
    <complexType>
        <sequence>
            <element ref="description" minOccurs="0" />
            <choice minOccurs="0">
                <element ref="bean" />
                <element ref="ref" />
                <element ref="idref" />
                <element ref="value" />
                <element ref="null" />
                <element ref="list" />
                <element ref="set" />
                <element ref="map" />
                <element ref="props" />
            </choice>
        </sequence>
        <attribute name="index" type="string" />
        <attribute name="type" type="string" />
        <attribute name="ref" type="string" />
        <attribute name="value" type="string" />
    </complexType>
</element>
<element name="description">
    <complexType mixed="true" />
</element>
<element name="list">
    <complexType>
        <choice minOccurs="0" maxOccurs="unbounded">
            <element ref="bean" />
            <element ref="ref" />
            <element ref="idref" />
            <element ref="value" />
            <element ref="null" />
            <element ref="list" />
            <element ref="set" />
            <element ref="map" />
            <element ref="props" />
        </choice>
        <attribute name="value-type" type="string" />
        <attribute name="merge" default="default">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="default" />
                    <enumeration value="false" />
                    <enumeration value="true" />
                </restriction>
            </simpleType>
        </attribute>
    </complexType>
</element>
<element name="map">
    <complexType>
        <sequence>
            <element ref="entry" minOccurs="0" maxOccurs="unbounded" />
        </sequence>
        <attribute name="value-type" type="string" />
        <attribute name="key-type" type="string" />
        <attribute name="merge" default="default">
            <simpleType>
                <restriction base="NMTOKEN">
                    <enumeration value="default" />
                    <enumeration value="false" />
                    <enumeration value="true" />
                </restriction>
            </simpleType>
        </attribute>
    </complexType>
</element>
<element name="idref">
    <complexType>
        <attribute name="bean" type="string" />
        <attribute name="local" type="IDREF" />
    </complexType>
</element>
<element name="key">
    <complexType>
        <choice>
            <element ref="bean" />
            <element ref="ref" />
            <element ref="idref" />
            <element ref="value" />
            <element ref="null" />
            <element ref="list" />
            <element ref="set" />
            <element ref="map" />
            <element ref="props" />
        </choice>
    </complexType>
</element>

Has anyone run into a similiar problem and know of any way to fix this?

  • 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-27T13:32:39+00:00Added an answer on May 27, 2026 at 1:32 pm

    For the concrete castor problem you should provide more information, I guess. It seems there’s a duplicate field, so go ahead and remove each “key” attribute one by one until it starts working.

    But it is a strange thing you are trying to do. Spring’s DTD/XSD are meant to provide XML configuration – they aren’t supposed to represent objects. If you want to configure spring with code rather than xml, use javaconfig.

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

Sidebar

Related Questions

I am trying to generate xml using jaxb. I created xsd and generated java
I am trying to generate Java classes using Eclipse (New Web Service Client). Eclipse
While trying to generate classes from a xsd, i got this error: java.lang.IllegalArgumentException: Illegal
I'm trying to write a program in Java that uses osql to generate a
Im trying to consume a Java web-service, that uses a certificate. I could generate
I'm trying to generate customized xml files from a template xml file in python.
I'm trying to use JAXB to unmarshal this file into Java objects. I know
I'm trying to generate Java classes from the FpML (Finanial Products Markup Language) version
I am trying to generate Java documentation in Eclipse. The source files are UTF-8
I'm trying to generate a sitemap.xml on the fly for a particular asp.net website.

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.