Pady,
please read inline.
Werner
Pady Srinivasan wrote:
Thx. It worked. But I am lost on why this strange naming convention.
I am not sure why you consider this naming convention to be strange, but
here's a fragment from the default castor.properties file:
# Defines the Naming "style" or conventions to use when creating XML names
# from Java class or field names.
# Valid values are as follows:
# -----------------------------------------------------------------
# lower (default) | All names are lowercase with hyphens
# | separating words.
# |
# | Example: personInfo = person-info
# -----------------------------------------------------------------
# mixed | All names are mixed case, with Uppercase
# | character as the first letter of a new word.
# |
# | Example: personInfo = personInfo
# | Example: FooBar = fooBar
# -----------------------------------------------------------------
# {Any ClassName} | Any Class which implements
# | org.exolab.castor.xml.XMLNaming
# -----------------------------------------------------------------
As you can see there's various way for defining which naming style to
use for introspection. By fedault, its's the 'lowewr' style. Feel free
to change this to meet your requirements by overriding this property in
a custom castor property file.
I
am sure you have explained this many times. When I use source generator
with my xsd having an element as "BalanceInfo" it generates a class
called "BalanceInfo.java".
Well, as you are not generating the descriptor classes, you'll loose all
information as defined by the XML schema. In other words, if there's no
descriptor classes, Castor will (have to) fall back to 'introspection'.
I hope this explain the behaviour you are seeing.
In my case, I had to generate the source
using -nomarshall and -nodesc. This is because of GWT having problems
serializing castor classes etc.
Mind letting us know what actually is preventing from using the
descriptor classes ?
But I am not sure why Castor would
generate source as defined in xsd but then expect the element in the
actual xml to be different. Also what happens during marshalling ? I
will try it out.
Thx
-- pady
------------------------------------------------------------------------
> Date: Tue, 8 Jan 2008 00:56:57 +0100
> From: [EMAIL PROTECTED]
> To: [email protected]
> Subject: Re: [castor-user] unmarshall with custom classes...
>
> Sure. The default naming conversion will translate the class name
> BalanceInfo.java to <balance-info>.
>
> Wernerhe
>
> Pady Srinivasan wrote:
> >
> > I know the issue. But not the solution. My child element was actually
> > "BalanceInfo" with an equivalent class "BalanceInfo.java". Even if I
> > chane my element name from "<BalanceInfo" to "<balanceInfo>" or
> > "<balanceinfo" castor is not able to figure out the class and I get a
> > null. If I change the class to "Balance" and use "<balance>"
everything
> > works. Any ideas ?
> >
> > Thx
> >
> > -- pady
> >
> >
> >
> >
------------------------------------------------------------------------
> > > Date: Tue, 8 Jan 2008 00:19:59 +0100
> > > From: [EMAIL PROTECTED]
> > > To: [email protected]
> > > Subject: Re: [castor-user] unmarshall with custom classes...
> > >
> > > No idea. Mind posting the relevant code fragments, i.e. Java
classed and
> > > XML document instances.
> > >
> > > Werner
> > >
> > > Pady Srinivasan wrote:
> > > >
> > > > I tried changing <Balance> to <balance> and I still get a null
for the
> > > > Balance reference.
> > > >
> > > > Thx
> > > >
> > > > -- pady
> > > >
> > > >
> > > >
> > > >
> >
------------------------------------------------------------------------
> > > > > Date: Mon, 7 Jan 2008 21:33:18 +0100
> > > > > From: [EMAIL PROTECTED]
> > > > > To: [email protected]
> > > > > Subject: Re: [castor-user] unmarshall with custom classes...
> > > > >
> > > > > Yes, use a mapping file. The problem is that you are *not*
using a
> > > > > mapping file, and as such Castor will be using introspection to
> > > > > determine a mapping between Java objects and XML artefacts. For
> > this to
> > > > > work, Castor is using some default naming convention, whereupon
> > it will
> > > > > e.g. assume that the artefact mapped to the Java class
Balance is
> > named
> > > > > <balance> (and not <Balance>).
> > > > >
> > > > > T overcome this problem, either define a mapping for these
> > > > > classes/members, or consider changing the XML to meet the
default
> > naming
> > > > > conventions for introspection mode.
> > > > >
> > > > > Regards
> > > > > Werner Guttmann
> > > > >
> > > > > Pady Srinivasan wrote:
> > > > > >
> > > > > > Hi. I have custom classes and would like to unmarshall an xml
> > to java
> > > > > > objects. The xml is as follows:
> > > > > >
> > > > > > <Account>
> > > > > > <id>324</id>
> > > > > > <Balance>
> > > > > > <amount>23.34</amount>
> > > > > > </Balance>
> > > > > > </Account>
> > > > > >
> > > > > > My unmarshall code is as follows:
> > > > > >
> > > > > > FileReader reader = new FileReader("account.xml");
> > > > > > Account account = Unmarshaller.unmarshall(Account.class,
reader);
> > > > > >
> > > > > > When I try to do a account.getBalance(), I get a "null"
instead
> > of a
> > > > > > Balance object. Account.java and Balance.java are Serializable
> > objects
> > > > > > and exist in the same package. Using Castor 1.1. Anything
> > special I
> > > > need
> > > > > > to do ?
> > > > > >
> > > > > > Thx
> > > > > >
> > > > > > -- pady
> > > > > >
> > > > > >
> > > >
> >
------------------------------------------------------------------------
> > > > > > Get the power of Windows + Web with the new Windows Live. Get
> > it now!
> > > > > >
> > <http://www.windowslive.com?ocid=TXT_TAGHM_Wave2_powerofwindows_012008>
> > > > >
> > > > >
> > > > >
> > > > >
---------------------------------------------------------------------
> > > > > To unsubscribe from this list please visit:
> > > > >
> > > > > http://xircles.codehaus.org/manage_email
> > > > >
> > > >
> > > >
> >
------------------------------------------------------------------------
> > > > Watch “Cause Effect,” a show about real people making a real
> > difference.
> > > > Learn more
> > <http://im.live.com/Messenger/IM/MTV/?source=text_watchcause>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe >from this list please visit:
> > >
> > > http://xircles.codehaus.org/manage_email
> > >
> >
> >
------------------------------------------------------------------------
> > Put your friends on the big screen with Windows Vista® + Windows
Live™.
> > Start now!
> >
<http://www.microsoft.com/windows/shop/specialoffers.mspx?ocid=TXT_TAGLM_CPC_MediaCtr_bigscreen_012008>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
> http://xircles.codehaus.org/manage_email
>
------------------------------------------------------------------------
Make distant family not so distant with Windows Vista® + Windows Live™.
Start now!
<http://www.microsoft.com/windows/digitallife/keepintouch.mspx?ocid=TXT_TAGLM_CPC_VideoChat_distantfamily_012008>
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email