aspose file tools*
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 Java 8 in Action this week in the Java 8 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: 18155
    
    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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAXB and XML default namespace issue.
 
Similar Threads
JSP Bean reference
How can I remove standalone="yes" and include xmlns:xsd and xsi in root
Question about generating XSD
Help needed in .EAR deployment on Oracle Application Server 10g
SpringSecurity-config.xml doesn´t find http tag