[EMAIL PROTECTED] wrote:
>
> We have the same problem, and removing the targetNamespace declaration is
> not possible since some XSD files are imported by others. Each imported
> XSD file must have a different target namespace.
Right...so in your case, you need to use namespaces, otherwise the xml
will be invalid if those namespaces don't exist.
> Also, the XSD we are using can not be modified since they are shared and
> used by other applications that make use of the namespaces.
>
> The best thing would be to have a way to tell Castor to generate or not
> the prefixes in XML files.
Then the XML generated would be invalid.
>
> It could be as simple as:
>
> marshaller.setMarshallWithPrefix( false );
>
If such a method existed, the XML generated would not be valid.
> Or
>
> marshaller.setNamespaceMapping( null, "http://www.xyz.com/mm" );
>
The above will use the namespace as the default one,
eg: xmlns="http://www.xyz.com/mm"
The same for
marshaller.setNamespaceMapping( "", "http://www.xyz.com/mm" );
--Keith
>
> But the first method does not exist and the second example does not work!!
> ;-)
>
> Maybe the solution is to set a property directly in the XML
> parser/generator used by Castor...?
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: June 7, 2004 3:16 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-user] ns prefix issue in caster marshalling
>
> 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
>
> -----------------------------------------------------------
> 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