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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:51:58+00:00 2026-06-13T22:51:58+00:00

I have an interesting XML situation in which I’m trying to write an XSD

  • 0

I have an interesting XML situation in which I’m trying to write an XSD for. The web service I am using has an unusual way of sending responses in that it is generic in a way.

For example,

Web Service Call 1:

<rootElement>
  <result>
    <resultset>
      <row attr="some value" attr2="some value 2" />
    </resultset>
  </result>
</rootElement>

Web Service Call 2:

<rootElement>
  <result>
    <resultset>
      <row someOtherAttr="some value" someOtherAttr2="some value 2" />
    </resultset>
  </result>
</rootElement>

As you can see, the only thing that differentiates the two web service responses is the attributes within the row element.

I’ve tried a few different approaches by having an abstract element for the result element, which works to a point, but I can’t figure out how allow JAXB to choose which result element to use when marshalling.

i.e.

... other xs declarations excluded for sanity ...
<xs:element ref="abstractResult" />
... snip ...

<xs:element name="abstractResult" type="ResultType" abstract="true" />

<xs:complexType name="ResultType" abstract="true" />

<xs:complexType name="SomeResultType">
  <xs:complexContent>
    <xs:extension base="ResultType">
... snip ...

The problem with this approach is JAXB tries to instantiate the abstract ResultType while marshalling rather than searching for a proper implementation.

Is there any way to avoid this?

Thanks a bunch!

  • 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-13T22:51:59+00:00Added an answer on June 13, 2026 at 10:51 pm

    Ended up separating the schemas into independent files in which there are the different implementations of the root element.

    I then tied the multiple schemas to their own namespace so the marshaller is able to differentiate between the similar elements.

    Since the xml comes in without a namespace from the webservice, I am using JDom to set the namespace since I know what the target object type will be at runtime.

    Hope this helps anyone interested.

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

Sidebar

Related Questions

I have an interesting scenario. I have a task model which has a task
I have an interesting problem, I have two web services defined in a spring-conf.xml
I have an interesting problem. I am using Ant which executes JUnit tests (test
I've got an interesting problem. I have an iPad App which has to parse
Have an interesting one. I'm documenting a method using XML documentation comments in C#.
I have a web server which contains a list of interesting locations. These are
I'm trying to parse a REST response which is in XML. The interesting thing
I have an interesting situation that EMF forced me into: abstract class AbstractDog{ ...
I have an interesting dilemma to which, I hope, someone may have an answer.
I have an activity using an xml layout where a WebView is embedded. 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.