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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:01:04+00:00 2026-05-24T12:01:04+00:00

I am trying to map a java model into some XML. To do this

  • 0

I am trying to map a java model into some XML. To do this I am using the MOXy implementation of JAXB. I have run into some troubles generating a valid XML Schema from the java model. I use the following model:

@XmlRootElement
public class FooBar {
    @XmlAttribute
    @XmlPath("test/@foo")
    private boolean foo;
}

And I am generating the schema with the following code:

public static void main(String[] args) throws Exception {
    final SchemaOutputResolver sor = new SchemaOutputResolver() {
        @Override
        public Result createOutput(String namespaceUri,
                String suggestedFileName) throws IOException {
            return new StreamResult(System.out);
        }
    };

    JAXBContext jc = JAXBContext.newInstance(FooBar.class);
    jc.generateSchema(sor);
}

And I use the following package-info.java file:

@XmlSchema(namespace = "http://moxy.test", elementFormDefault = XmlNsForm.QUALIFIED)
package test.moxy;

import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;

When running the test I obtain the following schema:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:ns0="http://moxy.test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://moxy.test" elementFormDefault="qualified">
   <xsd:complexType name="big">
      <xsd:sequence>
         <xsd:element name="test" minOccurs="0">
            <xsd:complexType>
               <xsd:sequence/>
               <xsd:attribute ref="ns0:foo"/>
            </xsd:complexType>
         </xsd:element>
      </xsd:sequence>
   </xsd:complexType>
   <xsd:element name="big" type="ns0:big"/>
   <xsd:attribute name="foo" type="xsd:boolean" use="required"/>
</xsd:schema>

It can be seen that the last attribute element is not what one would expect. If I remove the package-info.java file, the following schema is generated:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:complexType name="fooBar">
      <xsd:sequence>
         <xsd:element name="test" minOccurs="0">
            <xsd:complexType>
               <xsd:sequence/>
               <xsd:attribute name="foo" type="xsd:boolean" use="required"/>
            </xsd:complexType>
         </xsd:element>
      </xsd:sequence>
   </xsd:complexType>
   <xsd:element name="fooBar" type="fooBar"/>
</xsd:schema>

Which is what I would expect being generated. Does anyone know why this is the case?

  • 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-24T12:01:04+00:00Added an answer on May 24, 2026 at 12:01 pm

    UPDATE

    This issue (https://bugs.eclipse.org/354130) has now been fixed in our EclipseLink 2.3.1 and 2.4.0 streams, and will be available from our nightly download site starting August 9th, 2011:

    • http://www.eclipse.org/eclipselink/downloads/nightly.php
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to integrate some Google maps bits into my Java web app using
I'm trying to write a web application using SpringMVC. Normally I'd just map some
I'm trying to map java.util.Date to postgresql timestamp without time zone type. I'm using
Is this possible in Java: Map<SomeObject, Map<SomeOtherObject>> ? I'm trying Map<Integer, Map<String>> am getting
I'm trying to map a struct definition using ctypes: struct attrl { struct attrl
I am trying to integrate the function into a map where you can enter
I'm trying to make some types in Django that map to standard Django types.
I'm currently trying to map a java ArrayList with a Flex ArrayCollection, through LCDS.
I am trying to create a map from an interleaved list and running into
I have a Java method takes an argument of type Map<Long, Foo> . 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.