I'm trying to read 'test_output.xsd' (see below). This uses the two schemas 'Main.xsd' and 'MyData.xsd'. I'm able to use SourceGenerator to create classes from these schemas, and I used those classes to write 'test_output.xml'
However, when I try to use the classes to read 'test_output.xml', I get various errors depending on how I do it. The closest to what I want comes from using Marshaller.unmarshal without a mapping file. In that case, the classes are able to read "TheFirstName" and "TheSecondName" correctly, however they don't correctly deal with "ThisIsMyData". That subsection is provided as a String, rather than being converted into a MyDataELEM class. If I use a mapping file it throws a collection-related error, and if I call the MainELEM's unmarshal method it doesn't pick up any of the data. Putting both schemas into one file produced the same classes. Both schemas are just examples; in my project Main.xsd is much larger and I can't change it. MyData.xsd is basically just a holder for a few strings, and I can change it as necessary. I've uploaded a runnable example with source code, build.xml, etc. here: http://tolstoy.com/castor_test.zip ------- test_output.xml ----------- <?xml version="1.0" encoding="UTF-8"?> <Main xmlns="http://127.0.0.1:8080/foo"> <First> <FirstName>TheFirstName</FirstName> </First> <Second> <SecondName>TheSecondName</SecondName> </Second> <SomeData> <MyData> <name>ThisIsMyData</name> </MyData> </SomeData> </Main> ------- Main.xsd ----------- <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://127.0.0.1:8080/foo" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://127.0.0.1:8080/foo"> <xsd:complexType name="FirstType"> <xsd:sequence> <xsd:element name="FirstName" type="xsd:string"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="SecondType"> <xsd:sequence> <xsd:element name="SecondName" type="xsd:string"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="SomeDataType"> <xsd:sequence minOccurs="0" maxOccurs="unbounded"> <xsd:any namespace="##any" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:element name="SomeData" type="SomeDataType"/> <xsd:element name="Main"> <xsd:complexType> <xsd:sequence> <xsd:element name="First" type="FirstType" minOccurs="0"/> <xsd:element name="Second" type="SecondType" minOccurs="0"/> <xsd:element ref="SomeData" minOccurs="0"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> ------- MyData.xsd ----------- <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://127.0.0.1:8080/foo" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://127.0.0.1:8080/foo"> <xsd:complexType name="MyDataType"> <xsd:sequence> <xsd:element name="name" type="xsd:string" minOccurs="0" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="BlahType"> <xsd:sequence> <xsd:element name="MyData" type="MyDataType"/> </xsd:sequence> </xsd:complexType> </xsd:schema> ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-user
