Thanks Warner,
 Placing all the classes in the same namespace worked in removing the
xmlns="" tags.  I do seem to have something peculiar happening when I'm
trying to marshall an arraylist.  I have the following mapping:

<class name="test.Message" auto-complete="false">
                <map-to xml="ICHData" ns-uri=http://test.namespace/>

                <field name="recordList" collection="arraylist"
                        type="test.Record" container="false">
                        <bind-xml name="Recs" />
                </field>
        </class>
All the other fields map correctly, but this field still adds the xmlns=""
.  Here is a snippet of the output..
ICHData xmlns="http://test.namespace";>
<Recs xmlns="">
...everything else is properly marshalled.
Do I have to somehow put the arraylist in my namespace?

Thanks again,
P. shah


On 6/3/08, Premal Shah <[EMAIL PROTECTED]> wrote:
>
> Hello,
> That's a good point.  I did that because I didn't want the namespace to
> print there on the other lines.  Essentially, my client handed me the format
> that they required and I tried to use castor to emulate it.
>
>
>  On 6/3/08, Werner Guttmann <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
>>
>> just looking at both the XML output and the mapping file (fragments), I
>> have got a question: how come it's only the test.Message class that is
>> being mapped to the 'http://test.com' namespace ? Is this on intention ?
>> Shouldn't the other classes (at least test.Type) to assigned to the same
>> namespace (or any other, if you wish) ?
>>
>> Mapping one class to a namespace (by the means of a mapping file) and
>> another class not does not really make sense.
>>
>> Regards
>> Werner
>>
>> Premal Shah wrote:
>> > Hello,
>> > Thanks for your help.  Here is the attached code fragments:
>> >
>> > <class name="test.Message" auto-complete="false">
>> >           <map-to xml="XMLMessage" ns-uri="http://test.com"; />
>> >                 <field name="header" type="test.Header">
>> >                         <bind-xml name="Header" node="element" />
>> >                 </field>
>> >                 <field name="metadata" type="test.Metadata">
>> >                         <bind-xml name="Metadata" node="element" />
>> >                 </field>
>> >                 <field name="payload" type="test.Payload">
>> >                         <bind-xml name="Payload" node="element" />
>> >                 </field>
>> >         </class>
>> >
>> > <class name="test.Type" auto-complete="false">
>> >                 <map-to xml="Type" />
>> >                 <field name="key" type="java.lang.String">
>> >                 <bind-xml name="Key" node="element" />
>> >                 </field>
>> >                 <field name="value" type="java.lang.String">
>> >                 <bind-xml name="Value" node="element" />
>> >                 </field>
>> >         </class>
>> >
>> >
>> >
>> > ...other classes are defined here
>> >
>> >
>> >
>> > snipped of code:
>> >         Marshaller MessageMarshaller = new Marshaller(handler);
>>
>> >                          //MessageMarshaller.setSuppressNamespaces(true);
>> > //MessageMarshaller.setNamespaceMapping("",http://test.com);
>> >                         MessageMarshaller.setMapping(mapping);
>> >                         MessageMarshaller.marshal(message);
>> >                         Unmarshaller MessageUnmarshaller =new
>> > Unmarshaller(mapping);
>> >
>> >                         System.out.println(writer.toString());
>> >                         StringReader reader=new
>> > StringReader(writer.toString());
>> >                         Message x
>> > =(Message)MessageUnmarshaller.unmarshal(reader);
>> >
>> > System.out.println("Header:\n"+x.getHeader().print());
>> >
>> > System.out.println("Metadata:\n"+x.getMetadata().print());
>> >
>> > System.out.println("Payload:\n"+x.getPayload().print());
>> >
>> > snippet of xml produced:
>> >
>> > <?xml version="1.0" encoding="UTF-8"?>
>> > <XMLMessage xmlns="http://test.com";>
>> >     <Header xmlns="">
>> >         <MessageID>test</MessageID>
>> >         <MessageType>test</MessageType>
>> >         <MessageCategory>test</MessageCategory>
>> >         <AckStatus></AckStatus>
>> >         <Checksum>fff</Checksum>
>> >         <EncodeType>hhhh</EncodeType>
>> >         <Sender>mm</Sender>
>> >         <Recipient>kk</Recipient>
>> >         <EncryptionType></EncryptionType>
>> >     </Header>
>> >     <Metadata xmlns="">
>> >         <Type>
>> >             <Key>DCC</Key>
>> >             <Value>MSD</Value>
>> >         </Type>
>> > My client cannot handle the xmlns="", however when I uncomment the
>> following
>> > lines:
>> >
>> >      //MessageMarshaller.setSuppressNamespaces(true);
>> > //MessageMarshaller.setNamespaceMapping("",http://test.com);
>> >
>> > My xml looks like how my client requires it as follows but then my
>> > unmarshalled message is full of null objects.  I appreciate your insight
>> > into this.
>> >
>> > <XMLMessage xmlns="http://test.com";>
>> >    <Header>
>> > .......
>> >
>> >
>> >
>> >
>> >
>> > On 6/1/08, Werner Guttmann <[EMAIL PROTECTED]> wrote:
>> >> Hi,
>> >>
>> >> can you please give us some more code fragments to show what you are
>> >> doing ? I.e. a mapping file (fragment), XML being produced, etc.
>> >>
>> >> Regards
>> >> Werner
>> >>
>> >> Premal Shah wrote:
>> >>> Hello,
>> >>> I have generated a mapping file in which one class has a ns-uri
>> element
>> >> in
>> >>> the <map-to xml> tag.  The problem that I have is that after I
>> marshall
>> >>> this, the tags that are generated all have <xmlns=""> except for the
>> one
>> >>> that i have specified the ns-uri for.  However, I am able to correctly
>> >>> unmarshal the the xml back to the objects.  My clients parser cannot
>> >> handle
>> >>> the <xmlns=""> so I tried to use the
>> setsuppressedNamespaces(true).  This
>> >>> creates an xml format that is satisfactory, but the objects are null
>> when
>> >> I
>> >>> unmarshal them.
>> >>>
>> >>> Any insites into this problem?
>> >>>
>> >>> Thanks in advance,
>> >>> P. Shah
>> >>>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe from this list, please visit:
>> >>
>> >>    http://xircles.codehaus.org/manage_email
>> >>
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>

Reply via email to