You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by imorales <im...@ignos.com> on 2007/12/26 14:34:01 UTC

ClassCastException: org.apache.xmlbeans.impl.values.XmlComplexContentImpl

Hi all. I have a problem using xmlbeans 2.3.0. I tested for 2.2.0 and 2.1.0
and the problem still occurs that because I suppose the problem it´s in my
xsd code or java generated pojos with "scomp".

I get a ClassCastException when I call Factory.parse().
My schema is:
--------------------------
<?xml version="1.0" encoding="iso-8859-1"?>
<xs:schema xmlns:platino="http://platino.com/servicios/registro"
	       xmlns:xs="http://www.w3.org/2001/XMLSchema"
		   xmlns:tns="http://platino.com/servicios/registro"
	       targetNamespace="http://platino.com/servicios/registro"
	       elementFormDefault="qualified"
	       attributeFormDefault="unqualified">
<xs:attribute name="codigo" type="xs:integer">
	<xs:annotation>
	  <xs:documentation>
	    Código.
	  </xs:documentation>
	</xs:annotation>
 </xs:attribute>

<xs:element name="Asunto" type="platino:Asunto"/>
<xs:complexType name="Asunto" mixed="true">
	<xs:annotation>
	  <xs:documentation>
	    Asunto
	  </xs:documentation>
	</xs:annotation>
	<xs:sequence/>
	<xs:attribute ref="platino:codigo" use="optional"/>
</xs:complexType>
--------------------------

The that I execute is:
--------------------------
DOMResult dst = new DOMResult();
Source s = new StreamSource(new File("p:\\example.xml"));
TransformerFactory.newInstance().newTransformer().transform(s, dst);
AsuntoDocument dd = AsuntoDocument.Factory.parse(dst.getNode());
Asunto d = dd.getAsunto();
--------------------------

And the file that I parse is "example.xml":
--------------------------
<reg:Asunto codigo="12" xmlns:reg="http://platino.com/servicios/registro">
</reg:Asunto>
--------------------------

I use to compile the schema --> scomp -out reg-xmlbeans.jar reg.xsd
reg.xsdconfig -debug -verbose

Any ideas, thanks in advance.
-- 
View this message in context: http://www.nabble.com/ClassCastException%3A-org.apache.xmlbeans.impl.values.XmlComplexContentImpl-tp14502217p14502217.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: ClassCastException: org.apache.xmlbeans.impl.values.XmlComplexContentImpl

Posted by imorales <im...@ignos.com>.
I found the solution for me. The error was in the reg.xsdconfig. There is a
whitespace in the package element If I remove that whitespace and I compile
the schema I don´t got any Exceptions in the parse method.


imorales wrote:
> 
> Hi all. I have a problem using xmlbeans 2.3.0. I tested for 2.2.0 and
> 2.1.0 and the problem still occurs that because I suppose the problem it´s
> in my xsd code or java generated pojos with "scomp".
> 
> I get a ClassCastException when I call Factory.parse().
> My schema is:
> --------------------------
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xs:schema xmlns:platino="http://platino.com/servicios/registro"
> 	       xmlns:xs="http://www.w3.org/2001/XMLSchema"
> 		   xmlns:tns="http://platino.com/servicios/registro"
> 	       targetNamespace="http://platino.com/servicios/registro"
> 	       elementFormDefault="qualified"
> 	       attributeFormDefault="unqualified">
> <xs:attribute name="codigo" type="xs:integer">
> 	<xs:annotation>
> 	  <xs:documentation>
> 	    Código.
> 	  </xs:documentation>
> 	</xs:annotation>
>  </xs:attribute>
> 
> <xs:element name="Asunto" type="platino:Asunto"/>
> <xs:complexType name="Asunto" mixed="true">
> 	<xs:annotation>
> 	  <xs:documentation>
> 	    Asunto
> 	  </xs:documentation>
> 	</xs:annotation>
> 	<xs:sequence/>
> 	<xs:attribute ref="platino:codigo" use="optional"/>
> </xs:complexType>
> --------------------------
> 
> My xsdconfig is:
> --------------------------
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config">
>   <xb:namespace uri="##any">
>     <xb:package> com.platino.servicios.registro.sicres</xb:package>
>   </xb:namespace>
> </xb:config>
> --------------------------
> 
> The that I execute is:
> --------------------------
> DOMResult dst = new DOMResult();
> Source s = new StreamSource(new File("p:\\example.xml"));
> TransformerFactory.newInstance().newTransformer().transform(s, dst);
> AsuntoDocument dd = AsuntoDocument.Factory.parse(dst.getNode());
> Asunto d = dd.getAsunto();
> --------------------------
> 
> And the file that I parse is "example.xml":
> --------------------------
> <reg:Asunto codigo="12" xmlns:reg="http://platino.com/servicios/registro">
> </reg:Asunto>
> --------------------------
> 
> I use to compile the schema --> scomp -out reg-xmlbeans.jar reg.xsd
> reg.xsdconfig -debug -verbose
> 
> Any ideas, thanks in advance.
> 

-- 
View this message in context: http://www.nabble.com/ClassCastException%3A-org.apache.xmlbeans.impl.values.XmlComplexContentImpl-tp14502217p14503184.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org