users@jaxb.java.net

Namespace question

From: svennissel <sven.nissel_at_delphi.com>
Date: Mon, 3 Mar 2008 06:23:14 -0800 (PST)

I have some chaos with the namespaces.

My Schema
_________________________________________
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.test.com/test"
        xmlns:test="http://www.test.com/test">

        <complexType name="calibrationfile">
                <sequence minOccurs="1" maxOccurs="1">
                        <element name="description" type="string" minOccurs="0"
maxOccurs="1"></element>
                        <element name="products" type="test:products" minOccurs="1"
maxOccurs="1"></element>
                </sequence>
                <attribute name="revision" type="nonNegativeInteger"
use="required"></attribute>
        </complexType>
....
_________________________________________

My Root Class in Java
________________________________
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { "description", "products" })
@XmlRootElement(name = "calibrationfile")
public class Calibrationfile {
....
______________________________

My "Schema part" at the marshal process
________________________
String schemaPath = "http://www.test.com/test ee_schema.xsd";
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, schemaPath);
SchemaFactory sf =
SchemaFactory.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(schemaFile);
//marshaller.setSchema(schema);
____________________________

Now if i write the XML file, the Namespaces of the are not right.
"http://www.test.com/test" must be default, but it has the token ns2.
_________________________
<calibrationfile xmlns:ns2="http://www.test.com/test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.test.com/test ee_schema.xsd"> ....
_________________

The right xml file might be:
____________________________
<calibrationfile xmlns="http://www.test.com/test"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.test.com/test ee_schema.xsd ">
....
___________________________________


How can I configurate this in JAXB? I think i must add Annotations in the
package-info.java. But I don't now which.
-- 
View this message in context: http://www.nabble.com/Namespace-question-tp15804885p15804885.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.