hi,
i have an top level (document) element 'A' bound to java class 'TopLevelA'. further there is a nested element named 'A' as well, which is bound to 'NestedA'. (yes, the model is stupid, but i can't change...) on unmarshalling i get a 'NestedA' object instead of the expected 'TopLevelA'. i am using the 1.2.1-20080723.084025 snapshot available for download. in xsd that is: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xyz="http://www.xyz.com/" targetNamespace="http://www.xyz.com/" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xsd:element name="A" type="xyz:SomeType"/> <xsd:complexType name="AnotherType"> <xsd:simpleContent> <xsd:extension base="xsd:string"> </xsd:extension> </xsd:simpleContent> </xsd:complexType> <xsd:complexType name="SomeType"> <xsd:sequence> <xsd:element name="A" type="xyz:AnotherType" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:schema> the xml could be <?xml version="1.0" encoding="UTF-8"?> <xyz:A xsi:schemaLocation="http://www.xyz.com/ A.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xyz="http://www.xyz.com/"> <xyz:A>hello world</xyz:A> </xyz:A> the corresponding castor binding, which i wrote is: <?xml version="1.0" encoding="UTF-8"?> <binding xmlns="http://www.castor.org/SourceGenerator/Binding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.castor.org/SourceGenerator/Binding http://castor.org/binding.xsd" defaultBindingType="element"> <package> <name>com.xyz.model</name> <namespace>http://www.xyz/</namespace> </package> <elementBinding name="/A"> <java-class name="TopLevelA"/> </elementBinding> <elementBinding name="/complexType:SomeType/A"> <java-class name="NestedA"/> </elementBinding> </binding> the test fails: URL castrCdrUrl = getClass().getClassLoader().getResource("com/xyz/model/.castor.cdr"); assertNotNull(castrCdrUrl); assertTrue(castrCdrUrl.toString().contains("classes")); assertTrue(new File(castrCdrUrl.toURI()).exists()); XMLContext context = new XMLContext(); context.addPackage("com.xyz.model"); Unmarshaller unmarshaller = context.createUnmarshaller(); InputStream xmlStream = getClass().getClassLoader().getResourceAsStream("A.xml"); assertNotNull(xmlStream); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource is = new InputSource(xmlStream); Document xmlDocument = builder.parse(is); TopLevelA topLevelA = (TopLevelA) unmarshaller.unmarshal(xmlDocument); // <- classcastexception assertNotNull(topLevelA); assertNotNull(topLevelA.getNestedA(0)); assertEquals("hello world", topLevelA.getNestedA(0).getContent()); is this an issue to be reported via jira? regards, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DI Reinhard Weiss ANECON Software Design und Beratung G.m.b.H. Web: http://www.anecon.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Zusätzliche Pflichtangaben von Kapitalgesellschaften gem. § 14 UGB: FN166941b | Handelsgericht Wien | Firmensitz Wien --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

