posted 7 years ago
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.
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
posted 7 years ago
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.
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.
Time is what we want the most, but what we use the worst. -- William Penn
posted 2 years ago
We can generate namespace information using @XmlSchema annotation. It is a package level annotation which should be used in a special file called as "package-info.java". Shown below is how you can use it:
To generate the schema location information we can use the JAXB marshaller's JAXB_SCHEMA_LOCATION property as shown below:
For detailed information and working examples follow the link:
To generate the schema location information we can use the JAXB marshaller's JAXB_SCHEMA_LOCATION property as shown below:
For detailed information and working examples follow the link:
