Hi,
I am trying to unmarshal a document compliant with the following schema(since it's faily large schema,
I anclose what I believe is essential):
?xml version="1.0" encoding="UTF-8"?>
<xsd:include schemaLocation="file:///schemas/OtherType_1_0.xsd"/>
<xsd:element name="Result">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Version" type="xsd:string" fixed="Result_1_5.xsd"/>
<xsd:element name="ResultItemList">
<xsd:complexType>
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="ResultItem">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ItemLocator" type="OtherType">
<xsd:annotation>
<xsd:documentation>The contents of this element will match one of the ItemLocator schemas. Check the version tag to see which.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<<<<<<<<<<<<<<<<<<<< more elements here>>>>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
As a result, the following exception occurs at the line:
result = (Result) Unmarshaller.unmarshall(Result.class, doc)
org.xml.sax.SAXException: unable to add 'Version' to <ItemLocator> due to the following exception:
>>>--- Begin Exception ---<<<
java.lang.IllegalStateException: java.lang.ClassCastException: othertype.OtherType
at result.ResultDescriptor$1.setValue(ResultDescriptor.java:88)
at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:803)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:249)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
at org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:247)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
at org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:247)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
at org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:247)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
at org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:247)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
at org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:134)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:170)
at org.exolab.castor.xml.util.DOMEventProducer.start(DOMEventProducer.java:110)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:507)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:591)
at test.XMLCastorResultProcessor.processSearchResultDoc(XMLCastorResultProcessor.java:59)
at test.XMLCastorResultProcessor.main(XMLCastorResultProcessor.java:47)
>>>---- End Exception ----<<<
at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:836)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:249)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
at org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:247)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
at org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:247)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
at org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:247)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
at org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:247)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
at org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:134)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:170)
at org.exolab.castor.xml.util.DOMEventProducer.start(DOMEventProducer.java:110)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:507)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:591)
at test.XMLCastorResultProcessor.processResultDoc(XMLCastorResultProcessor.java:59)
The integrity of the input XML document, I believe, can be ruled out as a source of the problem.
The unmarshalling worked without problem until recently (including with the same input doc),
when it started failing in the above manner. I haven't changed my code or the inputs, which makes it even more puzzling.
I am new to Castor and, having exhausted the possiblities I could think of to resolve the problem,
decided to ask for some help as I run out if ideas.
The OtherType schema is:
<xsd:schema targetNamespace="http://schemas.proquest.com/mw" xmlns="http://schemas.proquest.com/mw" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xsd:element name="Other" type="AnyType">
<xsd:annotation>
<xsd:documentation>An example of an element that contains anything conforming to the schema guidelines.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:complexType name="OtherType">
<xsd:annotation>
<xsd:documentation>This type is used for elements that are defined in another schema that is versioned. The purpose is to avoid tying one schema to a specific version of another schema. The first tag of that other document should be a Version tag conforming to the schema guidelines.</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:any processContents="strict" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>Allow any kind of tags here without specifying what they are.</xsd:documentation>
</xsd:annotation>
</xsd:any>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Than you in advance for you input,
Luba
