Hi Theo, Alistair,


To set the namespace URI of a field whose name doesn't match it's
associated classes <map-to> xml name you can do the following in your
mapping file:

<mapping xmlns:ns1="my-namespace-uri">

  <class ...>
   <field name="name" type="MyNameType">
     <bind-xml name="ns1:myName">
   </field>
  </class>

</mapping>

Notice the declaration of the "ns1" prefix in the <mapping> element and
it's usage in the bind-xml name attribute.

I hope that helps,

--Keith


Theo Harper wrote:
> 
> As a follow-up to Alistair's questions, we have tracked the problem down to
> the following code:
> 
> UnmarshalHandler.java:
> 
> private void startElement
>         (String name, String namespace, AttributeSet atts)
>         throws SAXException
> 
> ....
> 
>                 //-- Namespace patch, should be moved to XMLClassDescriptor,
> but
>             //-- this is the least intrusive patch at the moment. kv -
> 20030423
>             if ((descriptor != null) && (!descriptor.isContainer())) {
>                 if ((namespace != null) && (namespace.length() > 0)) {
>                     if (!namespaceEquals(namespace,
> descriptor.getNameSpaceURI())) {
>                         //-- if descriptor namespace is not null, then we
> must
>                         //-- have a namespace match, so set descriptor to
> null,
>                         //-- or if descriptor is not a wildcard we can also
>                         //-- set to null.
>                         if ((descriptor.getNameSpaceURI() != null) ||
> (!descriptor.matches("*"))) {
>                             descriptor = null;
>                         }
> 
>                     }
>                 }
>             }
>             //-- end namespace patch
> 
> In our example, when we try to resolve the "my-marble" field the field
> descriptor that is returned does not contain a namespace URI.  Why is the
> namespace URI null for this field descriptor?  The code checks for primitive
> types and uses the parent class descriptors namespace URI but not other
> types.
> 
> The only way we seem to be able to unmarshal from file is to add a
> matches="*" to the mapping.xml file but this does not seem to be the right
> thing to do.
> 
> Any suggestions as to why this does not work would be much appreciated.
> 
> Thanks,
> Theo Harper
> 
> -----------------------------------------------------------
> 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