Roman,
no problem. Just to add a few things ....
Werner
Roman Klaehne wrote:
> Hi Werner,
>
>>> Another problem occurs when unmarshalling XMLs with more than one
>>> namespace. With Castor-Version 1.1.2 it works but with higher versions
>>> there are problems. It seems that order of namespace declarations at the
>>> root element is of importance. If I write the root element like
>>>
>>> <root xmlns="first/namespace" xmlns:other="other/namespace">
>>>
>>> the XML is read correctly. But if a write
>>>
>>> <root xmlns:other="other/namespace" xmlns="first/namespace">
>>>
>>> there are errors like
>>>
>>> The field '_element' (whose xml name is 'element') is a required field
>>> of class com.castorgen.ElementXml
>>>
>>> although the XML satisfies the schema.
>>>
>>> Do you know whether there are changes in higher version that handle
>>> namespace declaration in another way?
>> Not to my knowledge. Question: have you tried this with 1.2.x ? Or is
>> this really a regression problem introduced with 1.3 rc1 only ? If so,
>> please file a new Jira issue with a test case attached.
>
> With version 1.2 it doesn't work as with version 1.3rc1. But I didnt try
> all versions, only 1.1.2, 1.2 and 1.3rc1, so I don't know exactly in
> which version the "error" was introduced.
>
> Without making confusions it seems that the xerces version also plays a
> role. If I run the code with xerces version 2.8.1 then the actually
> working declarating
>
> <root xmlns="first/namespace" xmlns:other="other/namespace">
>
> also produce the error message above. If I use the newer version 2.9.1
> then there is no error.
I can report the same issue(s) here: there several Xerces releases
(2.5.x and 2.7.x) that cause our functional test suite to malfunction
completely (causing ~50 tests to fail out of 450). With 2.6.x and 2.9.x
everything seems to be fine.
Having said that, I'd still like you to raise a Jira issue and attach a
test case that we can use to replay your problem. Please do not forget
to include detailed instructions on the environment (Xerces versions,
etc.).
>
> Because I need that my code is running right know I replaced the
> two-namespace-schema with one having only one namespace.
>
> Best Regards
> /roman
>
>
>>> My problem is, that for my first problem I need the newest version
>>> (1.3rc1), but my second problem is only solved by an earlier version
>>> (e.g. 1.1.2).
>> I am three issues away of making 1.3 GA available; in other words, this
>> is the time to make any regression issues known to us.
>>
>>> Best regards
>>> /Roman
>>>
>>>
>>>
>>>
>>>
>>>>> Do you have any ideas regarding this strange behaviour?
>>>> No, not really. I am not sure whether this is a bug or not.
>>>>
>>>>> Thank you
>>>>> /roman
>>>>>
>>>>> Werner Guttmann schrieb:
>>>>>> Hi Roman,
>>>>>>
>>>>>> I just got your sample working (against SVN trunk) by changing the code
>>>>>> to unmarshal things to:
>>>>>>
>>>>>> XMLContext context = new XMLContext();
>>>>>> context.addPackage("your.package");
>>>>>>
>>>>>> Unmarshaller unmarshaller = context.createUnmarshaller();
>>>>>>
>>>>>> Reader source = new FileReader(exampleXml);
>>>>>> Object object = unmarshaller.unmarshal(source);
>>>>>>
>>>>>> I hope this helps.
>>>>>>
>>>>>> Regards
>>>>>> Werner
>>>>>>
>>>>>> Roman Klaehne wrote:
>>>>>>> Hi Werner,
>>>>>>>
>>>>>>>
>>>>>>> before creating a Jira issue I want to be sure whether I did all correct
>>>>>>> and that it is really a bug. It is that I need the functionality as soon
>>>>>>> as possible and I think it will take a quite long time for resolving the
>>>>>>> issue.
>>>>>>>
>>>>>>> For this reason I give you exactly the data of my simple test case,
>>>>>>> plain in this mail. It would be interesting whether you can reproduce
>>>>>>> the failure:
>>>>>>>
>>>>>>> The data:
>>>>>>>
>>>>>>> ########## XML-Schema #####################
>>>>>>> ###########################################
>>>>>>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>>>>>> elementFormDefault="qualified" attributeFormDefault="unqualified">
>>>>>>> <xs:element name="oneElement">
>>>>>>> <xs:complexType/>
>>>>>>> </xs:element>
>>>>>>> <xs:element name="otherElement">
>>>>>>> <xs:complexType/>
>>>>>>> </xs:element>
>>>>>>> </xs:schema>
>>>>>>> ########################################
>>>>>>> ########################################
>>>>>>>
>>>>>>> ########## Binding file ################
>>>>>>> ########################################
>>>>>>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>>>>>> <binding defaultBindingType="type">
>>>>>>> <package>
>>>>>>> <name>castorgen</name>
>>>>>>> <namespace></namespace>
>>>>>>> </package>
>>>>>>>
>>>>>>> <elementBinding name="oneElement">
>>>>>>> <java-class name="OneElementXml"/>
>>>>>>> </elementBinding>
>>>>>>> <elementBinding name="otherElement">
>>>>>>> <java-class name="OtherElementXml"/>
>>>>>>> </elementBinding>
>>>>>>> </binding>
>>>>>>> ########################################
>>>>>>> ########################################
>>>>>>>
>>>>>>> ########## exampleXml ##################
>>>>>>> ########################################
>>>>>>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>>>>>> <oneElement>
>>>>>>> </oneElement>
>>>>>>> ########################################
>>>>>>> ########################################
>>>>>>>
>>>>>>> The call to Unmarshaller producing the exception:
>>>>>>>
>>>>>>> ########################################
>>>>>>> ########################################
>>>>>>> Reader source = new FileReader(exampleXml);
>>>>>>> Unmarshaller unm = new Unmarshaller();
>>>>>>> Object o = unm.unmarshal(source);
>>>>>>> ########################################
>>>>>>> ########################################
>>>>>>>
>>>>>>> The used java libraries are listed below.
>>>>>>>
>>>>>>>
>>>>>>> Best Regards
>>>>>>> /Roman
>>>>>>>
>>>>>>> Werner Guttmann schrieb:
>>>>>>>> Sorry, Roman, but no attachments to any of the mailing lists, as
>>>>>>>> there's
>>>>>>>> no guarantee that they arrive at the other end.
>>>>>>>>
>>>>>>>> As already suggested, can you please create a new Jira issue and attach
>>>>>>>> your files ?
>>>>>>>>
>>>>>>>> Regards
>>>>>>>> Werner
>>>>>>>>
>>>>>>>> Roman Klaehne wrote:
>>>>>>>>> Hi Werner,
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> in the attachment you will find a very simple Eclipse project,
>>>>>>>>> containing
>>>>>>>>>
>>>>>>>>> (i) a simple XML Schema (in xml-schema/)
>>>>>>>>>
>>>>>>>>> (ii) a binding file for the schema (in xml-schema/castor-bindings)
>>>>>>>>>
>>>>>>>>> (iii) the generated class files (in lib/castorgen.jar)
>>>>>>>>>
>>>>>>>>> (iv) a simple class castor.test.Test (in src/)
>>>>>>>>>
>>>>>>>>> (v) two xml instances in (xml-instances/)
>>>>>>>>>
>>>>>>>>> (vi) an ant build file containing the tasks for generating the java
>>>>>>>>> sources and for compiling the Test class.
>>>>>>>>>
>>>>>>>>> The following libraries has to be on the classpath (see .classpath)
>>>>>>>>> and
>>>>>>>>> are not included in the attached ZIP file:
>>>>>>>>>
>>>>>>>>> ant-contrib.jar
>>>>>>>>> castor-1.2-anttasks.jar
>>>>>>>>> castor-1.2-codegen.jar
>>>>>>>>> castor-1.2.jar
>>>>>>>>> castor-1.2-xml.jar
>>>>>>>>> castor-1.2-xml-schema.jar
>>>>>>>>> commons-logging.jar
>>>>>>>>> serializer.jar
>>>>>>>>> velocity-dep.jar
>>>>>>>>> xalan-2.7.0.jar
>>>>>>>>> xercesImpl.jar
>>>>>>>>> xml-apis.jar
>>>>>>>>>
>>>>>>>>> When running the test class (specifying an xml instance, e.g.,
>>>>>>>>> xml-instances/oneElement.xml) the following exception occurs:
>>>>>>>>>
>>>>>>>>> Exception in thread "main" org.exolab.castor.xml.MarshalException: The
>>>>>>>>> class for the root element 'oneElement' could not be found.{File: [not
>>>>>>>>> available]; line: 2; column: 13}
>>>>>>>>> at
>>>>>>>>> org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:761)
>>>>>>>>> at
>>>>>>>>> org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:727)
>>>>>>>>> at
>>>>>>>>> org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:616)
>>>>>>>>> at castor.test.Test.main(Test.java:23)
>>>>>>>>> Caused by: org.xml.sax.SAXException: The class for the root element
>>>>>>>>> 'oneElement' could not be found.
>>>>>>>>> at
>>>>>>>>> org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1589)
>>>>>>>>> .....................
>>>>>>>>>
>>>>>>>>> What is going wrong?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Best Regards!
>>>>>>>>> /Roman
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Werner Guttmann schrieb:
>>>>>>>>>> Roman,
>>>>>>>>>>
>>>>>>>>>> a test case attached to a Jira issue. I don't see a reason why this
>>>>>>>>>> does
>>>>>>>>>> not work. Can you as such please create an issue at
>>>>>>>>>>
>>>>>>>>>> http://jira.codehaus.org/browse/CASTOR
>>>>>>>>>>
>>>>>>>>>> and attach a fully working test case. If you are using Maven,
>>>>>>>>>> there's an
>>>>>>>>>> archetype available to assist you with this (as documented at
>>>>>>>>>> http://castor.org/maven-archetypes.html).
>>>>>>>>>>
>>>>>>>>>> Regards
>>>>>>>>>> Werner
>>>>>>>>>>
>>>>>>>>>> Roman Klaehne wrote:
>>>>>>>>>>> Hi Werner,
>>>>>>>>>>>
>>>>>>>>>>>> that should work out of the box.
>>>>>>>>>>> This sounds good. I also thought that it should work.
>>>>>>>>>>>
>>>>>>>>>>>> When you used the XML code generator to
>>>>>>>>>>>> generate the Java classes from your XML schema, it produced
>>>>>>>>>>>> (so-called)
>>>>>>>>>>>> descriptor classes as well. Did you compile those as well, and are
>>>>>>>>>>>> these
>>>>>>>>>>>> available on your classpath as well ?
>>>>>>>>>>> Yes, the descriptor classes are generated and all generated classes
>>>>>>>>>>> are
>>>>>>>>>>> on the classpath.
>>>>>>>>>>>
>>>>>>>>>>> As I said the following code works fine:
>>>>>>>>>>>
>>>>>>>>>>> ***************************************************
>>>>>>>>>>> Unmarshaller u = new Unmarshaller(RootXml.class)
>>>>>>>>>>> Object o = u.unmarshal(reader)
>>>>>>>>>>> ***************************************************
>>>>>>>>>>>
>>>>>>>>>>> But if I instantiate the Unmarshaller without a "root class"
>>>>>>>>>>> argument
>>>>>>>>>>> (using the empty constructor), the error message
>>>>>>>>>>>
>>>>>>>>>>> "The class for the root element 'root' could not be found."
>>>>>>>>>>>
>>>>>>>>>>> arises.
>>>>>>>>>>>
>>>>>>>>>>> My XML-Schema also have a namespace. I don't know whether this is
>>>>>>>>>>> important. But my XML sources have a the same namespace of course.
>>>>>>>>>>>
>>>>>>>>>>> What more information you need to analyze this matter?
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> All the best
>>>>>>>>>>> /roman
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> Regards
>>>>>>>>>>>> Werner Guttmann
>>>>>>>>>>>>
>>>>>>>>>>>> Roman Klaehne wrote:
>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> I am using the Castor Source Code Generator together with Castor
>>>>>>>>>>>>> Unmarshaller.
>>>>>>>>>>>>>
>>>>>>>>>>>>> For the simple XML schema:
>>>>>>>>>>>>>
>>>>>>>>>>>>> *******************************************************************
>>>>>>>>>>>>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>>>>>>>>>>>> elementFormDefault="qualified" attributeFormDefault="unqualified">
>>>>>>>>>>>>> <xs:element name="root"/>
>>>>>>>>>>>>> <xs:element name="element"/>
>>>>>>>>>>>>> </xs:schema>
>>>>>>>>>>>>> *******************************************************************
>>>>>>>>>>>>>
>>>>>>>>>>>>> I have such a binding file:
>>>>>>>>>>>>>
>>>>>>>>>>>>> **************************************************
>>>>>>>>>>>>> <binding defaultBindingType="type">
>>>>>>>>>>>>> <elementBinding name="root">
>>>>>>>>>>>>> <java-class name="RootXml"/>
>>>>>>>>>>>>> </elementBinding>
>>>>>>>>>>>>> <elementBinding name="element">
>>>>>>>>>>>>> <java-class name="ElementXml"/>
>>>>>>>>>>>>> </elementBinding>
>>>>>>>>>>>>> </binding>
>>>>>>>>>>>>> **************************************************
>>>>>>>>>>>>>
>>>>>>>>>>>>> After generating the source code for the schema using the binding
>>>>>>>>>>>>> file
>>>>>>>>>>>>> above I want to unmarshall XML sources to the repective Java
>>>>>>>>>>>>> classes.
>>>>>>>>>>>>>
>>>>>>>>>>>>> When doing
>>>>>>>>>>>>>
>>>>>>>>>>>>> ***************************************************
>>>>>>>>>>>>> Unmarshaller u = new Unmarshaller(RootXml.class)
>>>>>>>>>>>>> Object o = u.unmarshal(reader)
>>>>>>>>>>>>> ***************************************************
>>>>>>>>>>>>>
>>>>>>>>>>>>> the object o is correctly unmarshalled and is an instance of class
>>>>>>>>>>>>> RootXml (as it should be).
>>>>>>>>>>>>>
>>>>>>>>>>>>> But when using the default constructor of Unmarshaller (without
>>>>>>>>>>>>> giving
>>>>>>>>>>>>> the root class RootXml.class) I get the following error message:
>>>>>>>>>>>>>
>>>>>>>>>>>>> "The class for the root element 'root' could not be found."
>>>>>>>>>>>>>
>>>>>>>>>>>>> My intention is to have XML documents with root elements "<root>"
>>>>>>>>>>>>> or
>>>>>>>>>>>>> "<element>" and when calling Unmarshaller.unmarshal() I don't
>>>>>>>>>>>>> know the
>>>>>>>>>>>>> type of the XML source (root or element). That means I want to do
>>>>>>>>>>>>> the
>>>>>>>>>>>>> following:
>>>>>>>>>>>>>
>>>>>>>>>>>>> ****************************************
>>>>>>>>>>>>> Unmarshaller u = new Unmarshaller();
>>>>>>>>>>>>> Object o = u.unmarshal();
>>>>>>>>>>>>>
>>>>>>>>>>>>> if(o instanceof RootXml) {
>>>>>>>>>>>>> doRoot();
>>>>>>>>>>>>> }
>>>>>>>>>>>>> else if(o instanceof ElementXml) {
>>>>>>>>>>>>> doElement();
>>>>>>>>>>>>> }
>>>>>>>>>>>>> ****************************************
>>>>>>>>>>>>>
>>>>>>>>>>>>> Do you have any ideas to get this working?
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks in advance and best regards
>>>>>>>>>>>>> /Roman Klähne
>>>>>>>>>>>>> (ZIB Berlin)
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>> 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
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> 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
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> 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
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>
>>
>
>
> ---------------------------------------------------------------------
> 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