This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes JAXB and XML default namespace issue. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB and XML default namespace issue." Watch "JAXB and XML default namespace issue." New topic
Author

JAXB and XML default namespace issue.

Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

Hi,

I am using JAXB 2.1.12 version to generate an xml.

Now my xml appears as:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<first_volume xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.company.com/firstVolume/1.0 first.xsd"
...........................>

I want it to be like the following

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<first_volume xmlns="http://www.company.com/firstVolume/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.company.com/firstVolume/1.0 first.xsd"
...........................>


I am not able to produce the default xmlns attribute, Please help...
Thanks in advance.


Time is what we want the most, but what we use the worst. -- William Penn
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

Nevermind guys, found the answer.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Excellent! Would you mind sharing the answer here, so that future victims of the problem can benefit?
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

Sorry.. here it is...

Everytime the JAXB object model is generated from the schema... it generates the "package-info.java" class, sometimes it generates the annotation for the default namespace...but sometimes it doesn't (dependent on the schema)

Adding the following annotation just above the package declaration gives us the default namespace attribute in the XML.

 
jQuery in Action, 2nd edition
 
subject: JAXB and XML default namespace issue.
 
Similar Threads
SpringSecurity-config.xml doesn´t find http tag
Question about generating XSD
JSP Bean reference
Help needed in .EAR deployment on Oracle Application Server 10g
How can I remove standalone="yes" and include xmlns:xsd and xsi in root