Hi James,
The code in the CVS is a little different than the code you are showing
here. Did you try to use the CVS version instead of 0.9.5? I believe it
already fixes the issue you are having.
Thanks,
--Keith
James Cowan wrote:
>
> I have been tracing through the way the code unmarshall xmls into an object
> and the problem is somewhere around line 1115 of UnMarshalhandler.java:
>
> while (descriptor == null) {
>
> descriptor = classDesc.getFieldDescriptor(name,
> NodeType.Element);
>
> //-- 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()
> )) {
> ; // descriptor = null;
> }
> }
> }
> //-- end namespace patch
>
> I commented out the descriptor = null (a heavy handed solution) and the
> unmarshalling now works.
>
> I think the problem is that the marshaller correctly puts the namespace of
> the imported schema into the xml, but the unmarshaller does not have the
> corresponding code.
>
> James
>
> ----- Original Message -----
> From: "James Cowan" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, August 26, 2003 4:26 PM
> Subject: Re: [castor-dev] SourceGenerator on multiple namespace when using
> wildcard in schema
>
> >
> > Hi
> >
> > I have run into the same problem when upgrading from castor 0.9.3 to
> castor
> > 0.9.5
> >
> > When I marshalled an object that referred to elements in another schema
> > using 0.9.3 I got the following xml:
> >
> > <?xml version="1.0"?>
> > <user_list_request><admin_user_id>jonathan</admin_user_id><xml_query xmlns
> > ="http://www.test.com/xml_utils"><xml_filter><column_name>user_status<
> >
> /column_name><operation>EQ</operation><value>DELETED</value></xml_filter><xm
> > l_so
> >
> rt><column_name>user_last_name</column_name><ascending>true</ascending><posi
> > tion
> > >0</position></xml_sort></xml_query></user_list_request>
> >
> > with castor 0.9.5 I get
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <user_list_request><admin_user_id>jonathan</admin_user_id><ns1:xml_query
> > xmlns:n
> >
> s1="http://www.test.com/xml_utils"><ns1:xml_filter><column_name>user_status<
> > /col
> >
> umn_name><operation>EQ</operation><value>DELETED</value></ns1:xml_filter><ns
> > 1:xm
> >
> l_sort><column_name>user_last_name</column_name><ascending>true</ascending><
> > posi
> > tion>0</position></ns1:xml_sort></ns1:xml_query></user_list_request>
> >
> > The latter causes an unmarshall error (it cannot find the field
> description
> > for xml_query).
> >
> > Is there anyway of suppressing the ns1?
> >
> > James
> >
> >
> > --------------------------------------------------------------------------
> --
> > ----
> >
> > Title: RE: [castor-dev] SourceGenerator on multiple namespace when using
> > wildcard in schema
> >
> >
> >
> > -----Original Message-----
> > From: Louise Wong
> > Sent: Friday, 13 June 2003 2:18 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: [castor-dev] SourceGenerator on multiple namespace when
> > using wildcard in schema
> >
> > I'm trying to convert an XML schema into Java class using castor
> > (v.0.9.5).
> > Then use org.exolab.castor.xml.Unmarshaller to unmarshall an
> > org.jdom.Document object to an XML message using these java classes.
> >
> > The XML schema looks like:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xs:schema targetNamespace="http://www.xxx.com/XMLData"
> > xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > xmlns="http://www.xxx.com.au/XMLData" elementFormDefault="qualified"
> > attributeFormDefault="unqualified">
> >
> > ....
> >
> > And the above schema is defined in it's parent schema as an "any"
> type
> > as below:
> >
> > <xs:complexType>
> > <xs:sequence>
> > <xs:any processContents="skip"
> > minOccurs="0" maxOccurs="unbounded"/>
> > </xs:sequence>
> > </xs:complexType>
> >
> > When I have unmarshalled the XML message using the above, the XML
> > message have the target namespace definition displayed on all the element
> > tags inside the "any" type element as below:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > ...
> > <ns1:Proposal xsi:type="Proposal" xmlns:ns1="any"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> > <ns2:CustName
> > xmlns:ns2="http://www.xxx.com/XMLData">ABC</ns2:CustName>
> > <ns3:CustRef
> > xmlns:ns3="http://www.xxx.com/XMLData">123</ns3:CustRef>
> > <ns4:CustAddress
> > xmlns:ns4="http://www.xxx.com/XMLData">abc</ns4:CustAddress>
> > <ns5:CustCode
> > xmlns:ns5="http://www.xxx.com/XMLData">123</ns5:CustCode>
> >
> > ....
> >
> > My question is : How can I perform the above conversion, so the
> > targe namespace only appear in the root element of the xml message instead
> > of appearing in all element tags.
> >
> > Note: I have tried using elementFormDefault="qualified" \and
> > elementFormDefault="unqualified" in the schema
> > and that it made no difference.
> >
> > -----------------------------------------------------------
> > 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
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev