Hi Sandeep,
Read Below...
Sandeep Khanna wrote:
Castor is not putting HashMap 'key' information as attribute as
configured in the mapping file.
I'm not positive this will work, but try taking the type attribute off
the Map collection field. For instance, without the type attribute in
the 'fields' field:
<field name="fields" collection="map">
In order for the generated XML to be Jibx compliant (this is for
comparing Castor & Jibx marshall/unmarshall similar documents)
Also, the following code was generated with:
Marshaller marshaller = new Marshaller( new
FileWriter( "AsXml-Castor.xml", false ) );
marshaller.setMapping( mapping );
marshaller.setSuppressNamespaces( false );
marshaller.setSuppressXSIType( false );
marshaller.marshal( clientDcl );
If you are trying to suppress XSI types and namespaces, you should be
setting those to true, not false, so:
marshaller.setSuppressNamespaces( true );
marshaller.setSuppressXSIType( true );
Mapping file:
<?xml version="1.0" encoding="UTF-8"?>
<mapping>
<!--
=================================================================== -->
<!-- Mapping for class com.adminserver.dcl.ClientDcl
-->
<!--
=================================================================== -->
<class name="com.adminserver.dcl.ClientDcl" identity="clientGuid"
access="shared"
auto-complete="false">
<field name="lastName" type="string" get-method="getLastName"
set-method="setLastName">
<bind-xml name="LastName" node="element"/>
</field>
<field name="fields" type="com.adminserver.dcl.ClientFieldDcl"
get-method="getFields"
set-method="setFields" collection="map">
<bind-xml name="entry" node="element" location="Fields">
<class name="org.exolab.castor.mapping.MapItem">
<field name="key" type="java.lang.String">
<bind-xml name="key" node="attribute"/>
</field>
<field name="value"
type="com.adminserver.dcl.ClientFieldDcl">
<bind-xml name="value"/>
</field>
</class>
</bind-xml>
</field>
</class>
<!--
=================================================================== -->
<!-- Mapping for class com.adminserver.dcl.ClientFieldDcl
-->
<!--
=================================================================== -->
<class name="com.adminserver.dcl.ClientFieldDcl"
identity="clientGuid fieldName" access="shared"
auto-complete="false">
<description>AsClientField</description>
<cache-type type="count-limited"/>
<map-to table="AsClientField" xml="AsClientField"/>
<field name="clientGuid" type="string"
get-method="getClientGuid" set-method="setClientGuid">
<bind-xml name="ClientGUID" node="element"/>
</field>
<field name="fieldName" type="string" get-method="getFieldName"
set-method="setFieldName">
<bind-xml name="FieldName" node="element"/>
</field>
<field name="textValue" type="string" get-method="getTextValue"
set-method="setTextValue">
<bind-xml name="TextValue" node="element"/>
</field>
<field name="fieldTypeCode" type="string"
get-method="getFieldTypeCode"
set-method="setFieldTypeCode">
<bind-xml name="FieldTypeCode" node="element"/>
</field>
</class>
</mapping>
Any ideas?
--Sandeep Khanna
Best,
Adam
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------