Hi Dan,

Can you open up a bug report at http://bugzilla.exolab.org. If you can attach a small-as-possible test case to the bug report that would be great. I'm actually working with the UnmarshalHandler at the moment and checked in a few fixes related to the location attribute though I don't think they are the same as what you're experiencing but you might want to try the latest CVS just to make sure.

Once I have something to run here I will be able to better assist you.

Thanks,

--Keith


Daniel Dyer wrote:
I have done some more digging and I have located the problem as being
the if statement on line 1786 of UnmarshalHandler.java (version 1.44 in
CVS).

At the moment the condition is:

        if ((descriptor == null) && (count == 0) &&
(!targetState.wrapper)) {

But this seems to be too restrictive for certain cases when using
auto-naming with the location attribute (sometimes the block of code
needs to be executed if count > 0).  I was able to get my stuff to work
by hardcoding the element names that auto-naming chooses, like this:

        if ((descriptor == null)
          && ((count == 0) || name.equals("MyElementName") ||
name.equals("MyOtherElementName"))
          && (!targetState.wrapper)) {

This works but is obviously not a good solution.  I then tried to come
up with a condition for the if that would make it work for the general
case (removing the count == 0 check altogether did not fix the problem).
Is spent a long time printing out all of the local variables and state
for each tag to try and work out was different about the tags that
caused the problem.  Eventually I came up with this ugly check that
seems to work in general:

        if ((descriptor == null)
          && ((count == 0) || (pathBuf != null &&
pathBuf.toString().equals(path)))
          && (!targetState.wrapper)) {

Being totally unfamiliar with Castor I've no idea why this works or how
it could be done better.  Perhaps someone who knows the code could
review this for me?  Keith?

Thanks,

Dan.


-----Original Message-----
From: Daniel Dyer Sent: 28 February 2005 16:48
To: 'castor-user@exolab.org'
Cc: 'castor-dev@exolab.org'
Subject: RE: "unable to find FieldDescriptor" when using auto-naming
with location attribute



I have been digging around in the source code and I think this is a bug in the UnmarshallHandler class. There is a count variable in the startElement(String name, String namespace, AttributeSet atts) method that seems to be causing some problems (the section of code in question begins on line 1724 in the latest CVS version of the file). I haven't fully got my head around what this code is doing but this count variable is being used in a couple of if statements and I don't think these conditional blocks are always being executed when they need to be.

If I remove the line that increments the count (line 1812) I sort of
solve the problem.  I can then use the location and auto-naming
attributes together in my mapping file and everything works as I would
expect.  However, if I try to use more than one level in the location
attribute (i.e. location="wrapper1/wrapper2") the problem comes back.
Can anybody give me some more insight into this section of code so that
I can make the necessary changes to get it working properly?

Thanks,

Dan.



------------------------------------------------------------------------

----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev



----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev

Reply via email to