Ok... I found a way to fix this.. But it's a bit overkill to have to create a new class Value only for holding a value of type java.lang.Object ...
Cheers, Robby <class name="com.nxp.spider2.e2eclient.domain.SearchCondition"> <map-to xml="SearchCondition" ns-uri="http://www.nxp.com/spider/logmonitor/schemas" ns-prefix="lm"/> <field name="expression" type="string"> <bind-xml name="Expression" node="element"/> </field> <field name="operator" type="string"> <bind-xml name="Operator" node="element"/> </field> <field name="values" type="com.nxp.spider2.e2eclient.domain.Value" collection="arraylist" handler="com.nxp.spider2.e2eclient.domain.handlers.ValueHandler"> <bind-xml name="Value"/> </field> </class> I had to use a handler to keep the namespace: ------------------------------------------------------------------------------------------ public class ValueHandler extends GeneralizedFieldHandler { @Override public Object convertUponGet(Object value) { return value; } @Override public Object convertUponSet(Object value) { return new Value(value); } @Override public Class<Value> getFieldType() { return Value.class; } } ------------------------------------------------------------------------------------------ public class Value implements Serializable { private static final long serialVersionUID = 3736749720659490433L; private Object value; public Value() { } public Value(Object value) { this.value = value; } public void setValue(Object value) { this.value = value; } public Object getValue() { return this.value; } } ------------------------------------------------------------------------------------------ -----Original Message----- From: Robby Pelssers [mailto:[email protected]] Sent: Wednesday, April 07, 2010 9:59 AM To: [email protected] Subject: [castor-user] [XML 1.3.1]: question with marshalling collection (namespace problem) Hi all, Below you will find relevant code snippets which I wrote uptill now. Everything seems ok except for values of a collection which don't inherit the namespace and prefix declared on the class mapping. Can someone explain how to fix this? Thx in advance, Robby Pelssers desired output: <lm:QueryLogEntryRequest xmlns:lm="http://www.nxp.com/spider/logmonitor/schemas"> <lm:SearchCondition xmlns:lm="http://www.nxp.com/spider/logmonitor/schemas"> <lm:Expression xmlns:lm="http://www.nxp.com/spider/logmonitor/schemas">currentStatus</lm:Expression> <lm:Operator xmlns:lm="http://www.nxp.com/spider/logmonitor/schemas">IN</lm:Operator> <lm:Value xsi:type="xs:string" xmlns:lm="http://www.nxp.com/spider/logmonitor/schemas" xmlns:xs="http://www.w3.org/2001/XMLSchema">Resend</lm:Value> <lm:Value xsi:type="xs:string" xmlns:lm="http://www.nxp.com/spider/logmonitor/schemas" xmlns:xs="http://www.w3.org/2001/XMLSchema">Imported</lm:Value> </lm:SearchCondition> </lm:QueryLogEntryRequest> current output: <?xml version="1.0" encoding="UTF-8"?> <lm:QueryLogEntryRequest xmlns:lm="http://www.nxp.com/spider/logmonitor/schemas"> <lm:SearchCondition> <lm:Expression>currentStatus</lm:Expression> <lm:Operator>IN</lm:Operator> <Value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://java.sun.com" xsi:type="java:java.lang.String">Resend</Value> <Value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://java.sun.com" xsi:type="java:java.lang.String">Ready to Send</Value> </lm:SearchCondition> </lm:QueryLogEntryRequest> ------------------------------------------------------------------------------------------ public class QueryLogEntryRequest extends AbstractRequest { private static final long serialVersionUID = -5127067437834047965L; private List<SearchCondition> searchConditions; public QueryLogEntryRequest() { searchConditions = new ArrayList<SearchCondition>(); } public List<SearchCondition> getSearchConditions() { return this.searchConditions; } public void setSearchConditions(List<SearchCondition> searchConditions) { this.searchConditions = searchConditions; } public void addSearchCondition(SearchCondition searchCondition) { getSearchConditions().add(searchCondition); } } ------------------------------------------------------------------------------------------ public class SearchCondition { private String expression; private String operator; private List<Object> values; private DataType dataType; public SearchCondition() { this.values = new ArrayList<Object>(); } public void setDataType(DataType dataType) { this.dataType = dataType; } public DataType getDataType() { return this.dataType; } public void setExpression(String expression) { this.expression = expression; } public String getExpression() { return this.expression; } public void setOperator(String operator) { this.operator = operator; } public String getOperator() { return this.operator; } public void setValues(List<Object> values) { this.values = values; } public List<Object> getValues() { return this.values; } public void addValue(Object value) { getValues().add(value); } } ------------------------------------------------------------------------------------------ current mapping: <?xml version="1.0"?> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.org/mapping.dtd"> <mapping> <description>Mapping of all e2e webservice pojo's</description> <class name="com.nxp.spider2.e2eclient.domain.SearchCondition"> <map-to xml="SearchCondition" ns-uri="http://www.nxp.com/spider/logmonitor/schemas" ns-prefix="lm"/> <field name="expression" type="string"> <bind-xml name="Expression" node="element"/> </field> <field name="operator" type="string"> <bind-xml name="Operator" node="element"/> </field> <field name="values" type="java.lang.Object" collection="arraylist"> <bind-xml name="Value"/> </field> </class> <class name="com.nxp.spider2.e2eclient.domain.QueryLogEntryRequest"> <map-to xml="QueryLogEntryRequest" ns-uri="http://www.nxp.com/spider/logmonitor/schemas" ns-prefix="lm"/> <field name="searchConditions" type="com.nxp.spider2.e2eclient.domain.SearchCondition" collection="arraylist"> <bind-xml name="SearchCondition"/> </field> </class> </mapping> ------------------------------------------------------------------------------------------

