Given that you create a new Jira issue at http://jira.codehaus.org/browse/CASTOR, and attach all relevant files (XML document, mapping file, Java classes), I'd be willing to have a look at this.
Werner llefever wrote: > Here's a bit clearer example of the problem: > > <?xml version="1.0" encoding="UTF-8"?> > <Visit sent-to-queue="false"> > <add-visit-datas id="0"> > <enhanced-session-id>123</enhanced-session-id> > <name>foo</name> > <value>bar</value> > </add-visit-datas> > <add-visit-datas id="0"> > <enhanced-session-id>123</enhanced-session-id> > <name>foo2</name> > <value>bar2</value> > </add-visit-datas> > <add-visit-datas id="0" > xsi:type="java:com.classesusa.beans.AddVisitData" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > <enhanced-session-id>123</enhanced-session-id> > <name>foo</name> > <value>bar</value> > </add-visit-datas> > <add-visit-datas id="0" > xsi:type="java:com.classesusa.beans.AddVisitData" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > <enhanced-session-id>123</enhanced-session-id> > <name>foo2</name> > <value>bar2</value> > </add-visit-datas> > </Visit> > > > Just yesterday end-of-day, I realized that, if this is any problem at all, > it's not the problem that was actually holding me up with my work (that was > 'downstream' of this Castor issue -- a Hibernate issue). However, this > Castor problem is perhaps still bona fide in terms of efficiency. > > That is, I now think that marshalling a Collection (in this case, > addVisitDatas) in such a way as to wrap sets of the members of the > Collection's element-type (in this case, AddVisitData) in an XML-element > named with the name of the Collection-variable (addVisitDatas) is preferable > to what one gets when one includes "container='false'", which wraps such > Collection-element data in an XML-element named with the Collection > element's type (AddVisitData). > > I now think that's actually more efficient, in that it saves on XML-elements > in the way it deals with the effectively anonymous Collection-elements. > > However, in the example above, those two add-visit-datas elements are > repeated. The second time, the only differences are the xsi:type and > xmlns:xsi attributes. Since, in this case, Castor is being used to marshall > objects through JMS-messaging, we're consequently sending messages that are > about twice as big as they need (or should need) to be. > > So, the upshot is that I now think there's really only one problem; and it's > not really holding me up; it's just a matter of currently sending a > needlessly fat message through JMS. > > Is there a way to send only the one set of two add-visit-datas elements, to > optimize the message? > > > > > > Keith Visco wrote: >> >> I'm having a bit of a problem understanding the issue. Can you provide an >> example of the object you are trying to marshal, the mapping file, the >> expected >> result and the actual result. I know you've provided pieces of this with >> an >> introductory explanation, but I am not following the problem with the >> pieces >> that you have provided. >> >> Thanks, >> >> --Keith >> >> >> llefever wrote: >>> There are two problems with the following result of marshalling. >>> >>> In that result, "more-visit-data" must have been derived from the >>> collection-variable named "moreVisitData" in class Visit; it appears as >>> many >>> times as should instances of the element it contains in Java -- of type >>> AddVisitData; meanwhile, the elements of the contained type are not in an >>> element called AddVisitData; I found something elsewhere about setting >>> "container='false'" on the field-element in the config; I tried that; it >>> seemed to work, except that there was still a doubling of the output, >>> with >>> the second instance of the whole message containing "xsi:type" and NOT >>> showing the beneficial effect of "container='false'". >>> >>> The Visit class has these methods on it: >>> >>> public void setMoreVisitData(Set moreVisitData) { >>> this.moreVisitData = moreVisitData; >>> } >>> >>> public Set getMoreVisitData() { >>> return moreVisitData; >>> } >>> >>> >>> I've so far killed an entire day tried to solve this problem. Any >>> feedback >>> would be much appreciated. >>> >>> >>> ======================================================= >>> >>> <?xml version="1.0" encoding="UTF-8"?> >>> >>> <Visit> >>> >>> <more-visit-data id="0"> >>> <enhanced-session-id>127.0.0.11174943003584</enhanced-session-id> >>> <name>foo</name> >>> <value>bar</value> >>> </more-visit-data> >>> >>> <more-visit-data id="0"> >>> <enhanced-session-id>127.0.0.11174943003597</enhanced-session-id> >>> <name>foo2</name> >>> <value>bar2</value> >>> </more-visit-data> >>> >>> ... >>> >>> <more-visit-data id="0" xsi:type="java:com.foo.beans.AddVisitData" >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> >>> <enhanced-session-id>127.0.0.11174943003584</enhanced-session-id> >>> <name>foo</name> >>> <value>bar</value> >>> </more-visit-data> >>> >>> ... >>> >>> </Visit> >>> >>> >>> ======================================================= >>> >>> Here's the config for that: >>> >>> <class name="com.foo.beans.Visit" auto-complete="true"> >>> <map-to xml="Visit"/> >>> >>> <field name="MoreVisitData" >>> type="com.classesusa.beans.AddVisitData" collection="set"/> >>> </class> >> >> --------------------------------------------------------------------- >> 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

