Werner,

I'm sorry, but I still don't understand if it's possible to skip over the root 
element when defining the highest level class.  It also appears there's no way 
to unmarshal a XML document that contains unmapped elements.  In other words, I 
want the following XPATH --> Class.property mappings.  

/config/gateway/name --> Gateway.name
/config/gateway/url --> Gateway.url
/config/gateway/anotherField --> NO MAPPING

Unfortunately I continue to get "unable to find FieldDescriptor for 'gateway' 
in ClassDescriptor of gateway" trying to skip over the root tag and map my 
com.mypackage.Gateway class.

<config>
   <gateway>
        <name></name>
        <url></url>
        <anotherField></anotherField>
        <action>
            <name></name>
            <ID></ID>
        </action>
        <action>
            <name></name>
            <ID></ID>
        </action>
  </gateway>
</config>

I tried using the root element as the bind mapping to my class in conjunction 
with the location attribute like so...

<class name="com.mypackage.Gateway" auto-complete="false">
 <map-to xml="config"/>
 <field name="name" type="java.lang.String">
     <bind-xml name="name" node="element" location="gateway"/>
 </field>
</class>
but get "unable to find FieldDescriptor for 'anotherField' in ClassDescriptor 
of gateway" for fields that are not described in the mapping document during 
unmarshalling.


----- Original Message ----
From: Werner Guttmann <[EMAIL PROTECTED]>
To: [email protected]
Sent: Thursday, March 29, 2007 8:01:09 AM
Subject: AW: AW: [castor-user] XML binding


1) auto-complete:

*auto-complete*: if true, the class will be introspected to determine its field 
and the fields specified in the mapping file will be used to override the field 
found during the introspection.

2) location attribute: 

The location attribute (as per 
http://castor.org/xml-mapping.html#6.-Location-attribute) does exist in the 
field mapping only. In other words, when specifying a field mapping for a 
(collection) member, you might actually 'inject' an arbitrary XPATH prefix to 
the actual field name (or corresponding XML name).

I hope this helps.
Werner

________________________________________
Von: Jon Wilmoth [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 29. März 2007 16:51
An: [email protected]
Betreff: Re: AW: [castor-user] XML binding

I thought I could control the "Castor XML introspector approach for all classes 
not mapped" by setting the class "auto-complete attribute" to false.  Is this 
not the case?
 
The location attribute sounds like a great way to ignore elements in an 
existing schema.  This would definitely work for some of the lower elements, 
but unfortunately this doesn't look like it works with the <map-to> element.  
What I think I need is something like this:
 
<class name="com.mypackage.Gateway" auto-complete="false">
 <map-to xml="config/gateway"/>
 <field name="name" type="java.lang.String">
     <bind-xml name="name" node="element"/>
 </field>
</class>
or 

<class name="com.mypackage.Gateway" auto-complete="false">
 <map-to xml="gateway" location="config"/>
 <field name="name" type="java.lang.String">
     <bind-xml name="name" node="element"/>
 </field>
</class>
 
Thanks,
Jon
----- Original Message ----
From: Werner Guttmann <[EMAIL PROTECTED]>
To: [email protected]
Sent: Thursday, March 29, 2007 12:18:46 AM
Subject: AW: [castor-user] XML binding
Hi,

If you don't provide a mapping for all classes involved, Castor XML will use an 
introspector approach for all classes not mapped (using some default naming 
conventions for working out member names etc.). 

To be honest, the error message 'unable to find FieldDescriptor for 'gateway' 
in ClassDescriptor of gateway' somehow does not make sense, but this might be a 
result of working in that 'mixed' mode.

Regards
Werner Guttmann

PS If you do not intend to provide a separate Java class (and a mapping) for 
the <config> element, you might want to consider the use of the location 
attribute (if applicable).

> -----Ursprüngliche Nachricht-----
> Von: Jon Wilmoth [mailto:[EMAIL PROTECTED]
> Gesendet: Donnerstag, 29. März 2007 01:39
> An: [email protected]
> Betreff: [castor-user] XML binding
> 
> I'm having problems mapping an existing XML document to existing classes
> using castor-0.9.5.3 and I'd like to know if I'm simply not doing
> something right or if the functionality doesn't exist in the version I'm
> using.
> With an XML doc something like:
> 
> <config>
>  <gateway>
>   <name></name>
>   <url></url>
>   <action>
>    <name></name>
>    <ID></ID>
>   </action>
>   <action>
>    <name></name>
>    <ID></ID>
>   </action>
>  </gateway>
> </config>
> 
> I'm trying unmarshal some elements, but not all to a class, but I'm
> getting an org.xml.sax.SAXException: unable to find FieldDescriptor for
> 'gateway' in ClassDescriptor of gateway".  I thought I'd start small, but
> the even the following mapping file won't unmarshall.
> 
> <class name="com.mypackage.Gateway" auto-complete="false">
>  <map-to xml="gateway"/>
>  <field name="name" type="java.lang.String">
>   <bind-xml name="name" node="element"/>
>  </field>
> </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


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to