Hi Dean, The namespace of the element <f> will be the target namespace of the parent <schema> in which <f> is declared. Even though the type for <f> is declared in a different namespace.
If you want <f> to be in the same namespace, you have to reference it and declare it in your other schema. For example: split-namespace-1.xsd: <element ref="test2:f"/> split-namespace-2.xsd: <element name="f" type="f"/> --Keith "Chalker, Dean" wrote: > > Hi Keith, > > At the risk of making a *complete* idiot of myself, I have a related > problem. With 0.9.5 and org.exolab.castor.builder.javaclassmapping=type and > a split schema in two namespaces: > > split-namespace-1.xsd:: > <?xml version="1.0" encoding="UTF-8"?> > <schema targetNamespace="http://www.xyz.com/test" > xmlns="http://www.w3.org/2001/XMLSchema" > xmlns:test="http://www.xyz.com/test" > xmlns:test2="http://www.xyz.com/test2" > elementFormDefault="qualified"> > <import namespace="http://www.xyz.com/test2" > schemaLocation="split-namespace-2.xsd"/> > > <complexType name="e"> > <sequence> > <element name="stringField" type="string"/> > <element name="intField" type="int"/> > <element name="f" type="test2:f"/> > </sequence> > </complexType> > </schema> > > split-namespace-2.xsd:: > > <?xml version="1.0" encoding="UTF-8"?> > <schema targetNamespace="http://www.xyz.com/test2" > xmlns="http://www.w3.org/2001/XMLSchema" > xmlns:test="http://www.xyz.com/test2" > elementFormDefault="qualified"> > > <complexType name="f"> > <sequence> > <element name="stringField" type="string"/> > <element name="intField" type="int"/> > </sequence> > </complexType> > </schema> > > Unmarshalling works as expected, but the following marshalling code: > > E e = new E(); > e.setStringField("aString"); > e.setIntField(1); > F f = new F(); > f.setStringField("bString"); > f.setIntField(2); > e.setF(f); > > Writer writer = new StringWriter(); > Marshaller.marshal(e, writer); > > yields: > > <?xml version="1.0" encoding="UTF-8"?> > <e xmlns="http://www.xyz.com/test"> > <stringField>aString</stringField> > <intField>1</intField> > <f> > <ns1:stringField > xmlns:ns1="http://www.xyz.com/test2">bString</ns1:stringField> > <ns2:intField > xmlns:ns2="http://www.xyz.com/test2">2</ns2:intField> > </f> > </e> > > I had expected to have f in the test2 namespace as well, perhaps something > like: > > <?xml version="1.0" encoding="UTF-8"?> > <e xmlns="http://www.xyz.com/test"> > <stringField>aString</stringField> > <intField>1</intField> > <ns1:f xmlns:ns1="http://www.xyz.com/test2"> > <ns1:stringField>bString</ns1:stringField> > <ns1:intField>2</ns1:intField> > </f> > </e> > > I promise this will be the last stupid question for a while :-)) > > Regards > Dean > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
