Here's an example, with generated code snippets:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0.0">
<xsd:element name="AKConfig" type="AKConfigType">
<xsd:annotation>
<xsd:documentation>AK Config</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:complexType name="AKConfigType">
<xsd:sequence>
<xsd:element name="handler" type="xsd:string" />
<xsd:element name="timeout" type="xsd:int" />
<xsd:element name="allowMultiplePartsPerCnxn"
type="xsd:boolean"
default="false" />
<xsd:element name="CategoryList"
type="CategoryListType" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CategoryListType">
<xsd:sequence>
<xsd:element name="CnxnCategory" type="CategoryType"
minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CategoryType">
<xsd:attribute name="value" type="xsd:string" use="required" />
<xsd:attribute name="MaxConnectionsAllowed" type="xsd:int"
use="optional"
default="1" />
</xsd:complexType>
</xsd:schema>
In the generated AKConfig.java, the unmarshal() method is:
public static com.ak.castor.AKConfigType unmarshal(
final java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException {
return (com.ak.castor.AKConfigType)
Unmarshaller.unmarshal(com.ak.castor.AKConfig.class, reader);
}
Why does this method return AKConfigType, and not AKConfig?
--aslam
a k'wala wrote:
>
> If my schema has the following:
>
> <xsd:element name="myElem" type="ElemType" />
> <xsd:complexType name="ElemType">
> ...
> </xsd:complexType>
>
> The unmarshal() methods generated for MyElem and ElemType, both, return
> type ElemType. Is there a way to have the one for MyElem return type
> MyElem?
>
> Background: I'm updating from Castor 0.9.* to the latest, and am getting
> ClassCastExceptions with the existing code, which wants the return type of
> unmarshal() to be that corresponding to the element name (MyElem), not its
> superclass (ElemType).
>
--
View this message in context:
http://www.nabble.com/unmarshal%28%29-method-for-named-element-with-%27type%27-attribute-tf4681201.html#a13396286
Sent from the Castor - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email