Andrew,

If you are having problems with naming conventions then it sounds like you may be using a static method on the Unmarshaller. The mapping file supports mixed case (camel case) names for elements and attributes.

The default introspector (by default) uses lower case names with a hyphen '-' to separate words. This can be configured in the castor.properties file to use mixed case as well.

So it sounds to me like default introspection was taking place and you mapping was being ignored.

In such situations, it's usually that a static method was being invoked on the Unmarshaller (or Marshaller). When using the static methods any mapping file set on the Unmarshaller will be ignored since a static method doesn't have access to non static variables.

--Keith


Andrew Eells wrote:
werner,

thanks for your concern. i'm fairly certain that i had problems with naming
conventions where i was using standard java names instead of '-' for xml
node elements and attributes, and i also think that my build script was not
working correctly - hence the problem lay elsewhere than castor!

thanks again!

andrew

-----Original Message-----
From: Werner Guttmann [mailto:[EMAIL PROTECTED] Sent: 17 December 2004 12:38
To: [EMAIL PROTECTED]
Subject: Re: [castor-user] XML - nested mapping issues in webapp vs. jUnit
test class



Andrew,

can you please post the full stack trace ?

Werner

werner,

i keep getting MappingException's thrown when attempting to set the
mapping
file onto the unmarshaller - but again, seems to work fine in a test
class...

andrew

-----Original Message-----
From: Werner Guttmann [mailto:[EMAIL PROTECTED] Sent: 15 December 2004 21:30
To: [EMAIL PROTECTED]
Subject: Re: [castor-user] XML - nested mapping issues in webapp vs. jUnit
test class



Andrew,

what problems are you experiencing ?

Werner

On Wed, 15 Dec 2004 17:54:27 -0000, Andrew Eells wrote:



i am attempting nested object mapping with castor xml and have problems

when

moving between a junit test class and a webapp i.e. the test class works
whereas the webapp mapping does not.


i am certain however, that this is NOT a classpath problem, the

classpaths

are identical in both environments as my first conclusion was that this
might be the issue...

i'm not ruling out the possibility that it is a fluke that it works in

the

standalone test class because my mapping configuration is not quite

correct!

i can't however find many examples of 3-level nested class mapping and

have

read reports of flakiness when performing nested mapping - if anyone else
has had similar problems or has any suggestions then i'd be really

grateful

to hear from you!

code snippets below... many thanks and kind regards, andrew eells


Mapping mapping = new Mapping(); mapping.loadMapping(mappingInputSource);

Unmarshaller unmarshaller = new Unmarshaller(ReportGroups.class);
unmarshaller.setMapping(mapping);

ReportGroups reportGroups = (ReportGroups)
unmarshaller.unmarshal(configInputSource);

data xml file content:

<report-groups baseDirectory="blah/blah">
  <report-group name="verticals" description="Verticals">
      <report name="report1" description="blah" config="more blah"/>
      <report name="report2" description="blah" config="more blah"/>
      <report name="report3" description="blah" config="more blah"/>
  </report-group>
  <report-group name="marketing" description="Marketing">
      <report name="report4" description="blah" config="more blah"/>
  </report-group>
</report-groups>


mapping file content:

<mapping>
  <class name="com.x.model.ReportGroups">
      <field name="reportGroups" collection="collection"
type="com.x.model.ReportGroup">
          <bind-xml name="report-groups" node="element"/>
      </field>
      <field name="baseDirectory" type="string">
          <bind-xml name="baseDirectory" node="attribute"/>
      </field>
  </class>

  <class name="com.x.model.ReportGroup">
      <field name="reports" collection="collection"
type="com.x.model.Report">
          <bind-xml name="report-group" node="element"/>
      </field>
      <field name="name" type="string">
          <bind-xml name="name" node="attribute"/>
      </field>
      <field name="description" type="string">
          <bind-xml name="description" node="attribute"/>
      </field>
  </class>

  <class name="com.x.model.Report">
      <field name="name" type="string">
          <bind-xml name="name" node="attribute"/>
      </field>
      <field name="description" type="string">
          <bind-xml name="description" node="attribute"/>
      </field>
      <field name="config" type="string">
          <bind-xml name="config" node="attribute"/>
      </field>
  </class>
</mapping>




________________________________________________________________________ This e-mail has been scanned for all viruses by MessageLabs.



----------------------------------------------------------- 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


________________________________________________________________________
This e-mail has been scanned for all viruses by MessageLabs.



________________________________________________________________________
This e-mail has been scanned for all viruses by MessageLabs.



----------------------------------------------------------- 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

Reply via email to