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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:25:07+00:00 2026-05-12T08:25:07+00:00

I have an XML that looks like this and a corresponding xsd with it.

  • 0

I have an XML that looks like this and a corresponding xsd with it.

<books>
  <book name="book1" id="book1">
    <name>Harry Potter</name>
  ...........
  </book>
  ...........
</books>

Please see that ‘name’ is appearing twice, once as an attribute in tag, and also as an element under tag. Apparently that is invalid syntax, I am not sure.

When I am trying to generate java classes for this using xjc command (of JAXB), it compains about the invalid duplicate entry in xsd file.

But, I am able to generate C# classes for the xsd using, xsd command in VS 2008.

I have three questions.

  1. Is that XML syntax wrong?

  2. Why is it that xjc(of JAXB) reports error while xsd(of VS2008) does not?

  3. Is there any way I can get xjc(of JAXB) to generate classes (without me having to alter the XML/XSD file) ?

I don’t want to alter XML/XSD file as it is 20,000 line file. But that is the last option for me.

  • 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-12T08:25:07+00:00Added an answer on May 12, 2026 at 8:25 am
    1. The schema isn’t wrong, but it is poorly designed. Using the same name for an attribute and a child element is confusing, although it is legal.
    2. Because they’re different tools that generate code for different languages.
    3. XJC can make use of “binding customizations” which allow you to influence how it generates the code. This includes the ability to change the generated java name for any given schema element. This is documented in the JAXB tutorial (see chapter 5, specifically 5.3)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have XML that looks like this: <Parameter Name=parameter name Value=parameter value /> which
So I have xml that looks like this: <todo-list> <id type=integer>#{id}</id> <name>#{name}</name> <description>#{description}</description> <project-id
I have a XML Structure that looks like this. <sales> <item name=Games sku=MIC28306200 iCat=28
I have some XML code that looks like this <SEARCHRESULTS> <FUNCTION name=BarGraph> <PARAMETER name=numList></PARAMETER>
I have an XML Schema that looks like this: <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=root> <xs:complexType>
I have an XML that looks like this <Labs> <Lab id=a name=a> <Test name=aa></Test>
If I have an XML node that looks like this <node name=a> <element ref=bb
I have a source xml that looks something like this: <item> <id>1</id> <property name=representative_email><value>Jallu.Kola@foo.bar.com</value></property>
I have XML that looks like this: <ROW ref=0005631 type=04 line=1 value=Australia/> <ROW ref=0005631
I have XML that looks something like this: <Root xmlns=http://widgetspecA.com/ns> ...any... <WidgetBox> <A/> <B/>

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.