If you have a targetNamespace in your schema, Castor will use it. So if
you don't want any namespaces in your output, then you have to remove
the targetNamespace from the schema before generating the sources.

If you just don't like the prefixes that castor chooses, you can declare
them yourself:

marshaller.setNamespaceMapping("xyz", "http://www.xyz.com/mm";);

This will use "xyz" instead of "ns1". It will also prevent Castor from
repeating the namespace declarations since you'll be declaring this at
the root level.

--Keith



highmark m wrote:
> 
> Anyway I am having an issue with castor.
> I have generated java classes from schema using
> castor. now when I marshall to xml file using
> castor marshalling apu, my xml file has every element
> except root element is prefixed with ns1:  ns2: ns3:
> and so so. this is a big problem for my application.
> how do i tell caster not to insert any prefixes.
> 
> Here is a part of generated xml:
> <newsletter article-count="14" valid="true">
>   <ns1:return-address
> xmlns:ns1="http://www.xyz.com/mm";><ns1:name> Book
> Services <
> .........................
> </ns3:article><ns4:article articleSize="medium"
> articleCat="Health"
> xmlns:ns4="http://www.xyz.com/mm";><ns4:headline>
> 
> It even named repeated elements (article) with
> different ns prefixes. It also inserted attribute:
> article-count="14"  which is no where in the java
> classes generated by castor or in the schema. How do i
> tell castor not to do this?
> 
> I also tried to do:
> 
> 
>       Marshaller ml = new Marshaller(writer);
>       ml.setDebug(true);
>       ml.setMarshalAsDocument(true);
>       ml.setMarshalExtendedType(false);
>      ml.setNSPrefixAtRoot(false);
>       ml.setSuppressXSIType(true);
>       ml.marshal(nwletter);
> 
> but that did not help.
> 
> I am awaiting answer on this.
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Friends.  Fun.  Try the all-new Yahoo! Messenger.
> http://messenger.yahoo.com/
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to