Skip to main content

@XmlType namespace attribute is empty after generating code (JAXB 2.1.5)

3 replies [Last post]
awolfard
Offline
Joined: 2003-06-12

Hi,

I have the following xsd:
<?xml version="1.0" encoding="UTF-8"?>

I generate the code:
xjc -p nl.test.jaxb bug.xsd > output.txt

The error response object is create with the following @XmlType:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ErrorResponse", propOrder = {
"errorcode",
"description"
})
public class ErrorResponse {
....
}

I would expect that the @XmlType annotation has an attribute namespace="http://www.test.nl/ws/messages/v1.0".

Is there a way to achieve this (so to have an attribute namespace="http://www.test.nl/ws/messages/v1.0")?

With kind regards,

Arnoud.

typo

Message was edited by: awolfard

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tigera
Offline
Joined: 2007-07-15

Check to see that a package-info.java file was generated with the annotation at package level. It might be in there.

awolfard
Offline
Joined: 2003-06-12

Thanks you are right! I can use this info to find a workaround for the problem I faced.

Do you or anybody else knows what the rules are for the default namespace when I use multiple namespaces in different schema's?

For instance when I import a schema with another namespace in a schema?

Which one will be namespace in the package-info.java?

With kind regards,

Arnoud.

tigera
Offline
Joined: 2007-07-15

My experience has been that the XmlNs attributes are all located in the package-info.java; if one schema imports another, both of them will appear as different XmlNs attributes in the same file, unless you specify that the namespaces should be in different packages. Remember that a binding customization may change this behavior.