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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:09:08+00:00 2026-05-19T17:09:08+00:00

I have two XML examples that I want to write a schema for: Example

  • 0

I have two XML examples that I want to write a schema for:

Example 1:

<attributes>
<attribute type="test" value="yes"/>
</attributes>

Example 2:

<attributes>
<attribute type="test">
<value x="100" y="50">yes</value>
</attribute>
</attributes>

Example 3:

<attributes>
<attribute type="test" value="no">
<value x="100" y="50">yes</value>
</attribute>
</attributes>

Is it possible to have a schema that works for these? With ‘value’ being an attribute in one and an element in the other?

Update
Right, I think I understand my problem now.

I have this XSD:

<xs:complexType name="Attribute">
   <xs:sequence >
      <xs:element name="value" type="Value" minOccurs="0" maxOccurs="unbounded">
      </xs:element>
   </xs:sequence>
   <xs:attribute name="type" type="xs:string" use="required">
   </xs:attribute>
   <xs:attribute name="value" type="xs:string" >
   </xs:attribute>
</xs:complexType>

But when I try to use JAXB to generate java classes from the XSD I get an error:

  [xjc] [ERROR] Property "Value" is already defined. Use &lt;jaxb:property> to resolve this conflict.
  [xjc]   line 275 of file:common.xsd
  [xjc] [ERROR] The following location is relevant to the above error
  [xjc]   line 286 of file:common/common.xsd
  [xjc] failure in the XJC task. Use the Ant -verbose switch for more details

I guess this is a limitation in JAXB rather than the XSD. It will try to create two methods called getValue() which will fail.

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

    The answer is ‘yes’, but if you want an if/else statement in the schema based on the value attribute then the answer is ‘no’. You just create the xsd with all of the attributes and elements values as optional and the document will validate fine. What an xsd validation will do for you is to tell you that document is valid under the rules specified in the schema, but what it does not do is process the data inside document like the actual yes/no value of the value attribute.

    If you post the schema that you currently have and have questions on what it should look like, you will get more specific schema feedback.

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

Sidebar

Related Questions

I have two applications written in Java that communicate with each other using XML
Are there any tools to effectively compare two XML schema's? I have seen some
I have two XML files with two different XSD schemas and different namespaces. They
I have two XML files. They are similar, but there are two nodes of
I have parsed XML using both of the following two methods... Parsing the XmlDocument
I have an xml file like this: <root> <item> <name>one</name> <status>good</status> </item> <item> <name>two</name>
I have two arrays of animals (for example). $array = array( array( 'id' =>
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have XML coming from a source that I can't change. They send it
I have two elements: <input a> <input b onclick=...> When b is clicked, I

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.