Index: src/main/java/org/exolab/castor/xml/schema/ElementDecl.java =================================================================== --- src/main/java/org/exolab/castor/xml/schema/ElementDecl.java (Revision 6908) +++ src/main/java/org/exolab/castor/xml/schema/ElementDecl.java (Arbeitskopie) @@ -861,6 +861,14 @@ private void setSchema(final Schema schema) { _schema = schema; } + + /** + * Indicates whether a type is set for this element definiion. + * @return True if a type is set. + */ + public boolean hasXMLType() { + return (_xmlType != null); + } } //-- Element Index: src/main/java/org/exolab/castor/xml/schema/AttributeDecl.java =================================================================== --- src/main/java/org/exolab/castor/xml/schema/AttributeDecl.java (Revision 6908) +++ src/main/java/org/exolab/castor/xml/schema/AttributeDecl.java (Arbeitskopie) @@ -627,4 +627,12 @@ _schema = schema; } + /** + * Indicates whether a type is set for this element definiion. + * @return True if a type is set. + */ + public boolean hasXMLType() { + return (_simpleType != null); + } + } //-- AttrDecl Index: src/main/java/org/exolab/castor/xml/schema/TypeReference.java =================================================================== --- src/main/java/org/exolab/castor/xml/schema/TypeReference.java (Revision 6908) +++ src/main/java/org/exolab/castor/xml/schema/TypeReference.java (Arbeitskopie) @@ -117,11 +117,16 @@ catch (IllegalArgumentException iax) { exception = iax; } - if (referredType != null) return; //we found it, return it + if (referredType != null) { + return; + } + //-- try to find a complex type - referredType= getSchema().getComplexType(getName()); + referredType = getSchema().getComplexType(getName()); - if (referredType != null) return; //we found it, return it + if (referredType != null) { + return; + } //-- rethrow exception if necessary if (exception != null) throw exception; Index: xmlctf/tests/MasterTestSuite/sourcegenerator/typeResolution/test.xsd =================================================================== --- xmlctf/tests/MasterTestSuite/sourcegenerator/typeResolution/test.xsd (Revision 0) +++ xmlctf/tests/MasterTestSuite/sourcegenerator/typeResolution/test.xsd (Revision 0) @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + Index: xmlctf/tests/MasterTestSuite/sourcegenerator/typeResolution/TestDescriptor.xml =================================================================== --- xmlctf/tests/MasterTestSuite/sourcegenerator/typeResolution/TestDescriptor.xml (Revision 0) +++ xmlctf/tests/MasterTestSuite/sourcegenerator/typeResolution/TestDescriptor.xml (Revision 0) @@ -0,0 +1,14 @@ + + + Collection of tests for (failing) type resolution + Werner Guttmann + See CASTOR-1917 + basic capability + + test.xsd + + Test Source Generation + true + + + Index: codegen/src/main/java/org/exolab/castor/builder/MemberFactory.java =================================================================== --- codegen/src/main/java/org/exolab/castor/builder/MemberFactory.java (Revision 6908) +++ codegen/src/main/java/org/exolab/castor/builder/MemberFactory.java (Arbeitskopie) @@ -327,8 +327,16 @@ //-- treat unspecified type as anyType switch (component.getAnnotated().getStructureType()) { case Structure.ATTRIBUTE: + AttributeDecl attribute = (AttributeDecl) component.getAnnotated(); + if (!attribute.hasXMLType()) { + xsType = new XSClass(SGTypes.OBJECT); + } + break; case Structure.ELEMENT: - xsType = new XSClass(SGTypes.OBJECT); + ElementDecl element = (ElementDecl) component.getAnnotated(); + if (!element.hasXMLType()) { + xsType = new XSClass(SGTypes.OBJECT); + } break; default: // probably a model-group