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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:19:48+00:00 2026-05-24T03:19:48+00:00

When I use @XmlSchema(attributeFormDefault = XmlNsForm.QUALIFIED, …) or @XmlAttribute(namespace = sample.com/y, …) JAXB ignores

  • 0

When I use @XmlSchema(attributeFormDefault = XmlNsForm.QUALIFIED, ...)

or@XmlAttribute(namespace = "sample.com/y", ...)

JAXB ignores @XmlSchema(namespace = "sample.com/x", ...)

and instead of:

<a xmlns="sample.com/y" xmlns:ns0="sample.com/y">
  <b ns0:att=""/>
</a>

generates something like:

<ns1:a xmlns:ns1="sample.com/x" xmlns:ns0="sample.com/y">
  <ns1:b ns0:att=""/>
</ns1:a>

Is this an expected behavior? Is there any way to correct 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-24T03:19:49+00:00Added an answer on May 24, 2026 at 3:19 am

    EclipseLink JAXB (MOXy) is handling the prefix qualification for elements differently depending upon the attribute form qualification (as demonstrated below).

    The namespace qualification is not wrong, but I agree that the use of default namespace is better when possible. You can track the progress on this issue using the following bug:

    • https://bugs.eclipse.org/353042

    A

    package forum6808921;
    
    import javax.xml.bind.annotation.XmlRootElement;
    
    @XmlRootElement
    public class A {
    
        private String b;
    
        public String getB() {
            return b;
        }
    
        public void setB(String b) {
            this.b = b;
        }
    
    }
    

    Demo

    package forum6808921;
    
    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.Marshaller;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            JAXBContext jc = JAXBContext.newInstance(A.class);
    
            A a = new A();
            a.setB("Hello World");
    
            Marshaller marshaller = jc.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            marshaller.marshal(a, System.out);
        }
    
    }
    

    package-info without attributeFormDefault set

    @XmlSchema(
            namespace = "sample.com/x"
            , elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED
            )
    package forum6808921;
    
    import javax.xml.bind.annotation.*;
    

    Output:

    <?xml version="1.0" encoding="UTF-8"?>
    <a xmlns="sample.com/x">
       <b>Hello World</b>
    </a>
    

    package-info with attributeFormDefault set

    @XmlSchema(
            namespace = "sample.com/x"
            , elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED
            , attributeFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED
            )
    package forum6808921;
    
    import javax.xml.bind.annotation.*;
    

    Output:

    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:a xmlns:ns0="sample.com/x">
       <ns0:b>Hello World</ns0:b>
    </ns0:a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following elements in my schema: <xs:schema attributeFormDefault=unqualified elementFormDefault=qualified xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:complexType name=optimizeModelBase>
I use the following XmlSchema: <?xml version=1.0 encoding=UTF-8?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema targetNamespace=http://www.test.com/XmlValidation elementFormDefault=qualified attributeFormDefault=unqualified xmlns:m=http://www.test.com/XmlValidation>
I want to create the following element: <exercises xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="mySchema.xsd"> If I use something
So in my current project I use the JAXB RI with the default Java
i have this xml schema <?xml version=1.0 encoding=UTF-8?> <xs:schema xmlns=http://hidden/abc xmlns:xs=http://www.w3.org/2001/XMLSchema targetNamespace=http://hidden/abc elementFormDefault=qualified attributeFormDefault=unqualified
i use the following XSLT by using XMLSpy: <?xml version=1.0 encoding=UTF-16?> <xsl:stylesheet version=2.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform
I tend to use external JAXB bindings files for my Schema-to-Java compilation. This works
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
Use case: A does something on his box and gots stuck. He asks B
Use case: 3rd party application wants to programatically monitor a text file being generated

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.