Skip to content
Browse files

GEOT-4287: Anonymous types handling are broken in app-schema

  • Loading branch information...
1 parent 95c0946 commit b35d1305ea8d54999b5a75e8a3378db18a192893 @riniangreani riniangreani committed
View
26 ...schema/app-schema/src/main/java/org/geotools/data/complex/config/FeatureTypeRegistry.java
@@ -412,8 +412,12 @@ private AttributeType getTypeOf(XSDElementDeclaration elemDecl, CoordinateRefere
if (elemDecl.isElementDeclarationReference()) {
elemDecl = elemDecl.getResolvedElementDeclaration();
}
+ boolean hasToBeRegistered = false;
typeDefinition = elemDecl.getAnonymousTypeDefinition();
if (typeDefinition == null) {
+ // anonymous types already has type definition inline in the element
+ // so the handling is different
+ hasToBeRegistered = true;
typeDefinition = elemDecl.getTypeDefinition();
}
@@ -446,11 +450,23 @@ private AttributeType getTypeOf(XSDElementDeclaration elemDecl, CoordinateRefere
throw new NoSuchElementException(msg);
}
- String targetNamespace = typeDefinition.getTargetNamespace();
- String name = typeDefinition.getName();
- Name typeName = Types.typeName(targetNamespace, name);
-
- return getAttributeType(typeName, typeDefinition, crs);
+ AttributeType type;
+ if (hasToBeRegistered) {
+ String targetNamespace = typeDefinition.getTargetNamespace();
+ String name = typeDefinition.getName();
+ Name typeName = Types.typeName(targetNamespace, name);
+ type = getAttributeType(typeName, typeDefinition, crs);
+ if (type == null) {
+ type = createType(typeName, typeDefinition, crs, false);
+ }
+ } else {
+ String name = elemDecl.getName();
+ String targetNamespace = elemDecl.getTargetNamespace();
+ Name overrideName = Types.typeName(targetNamespace, name);
+ type = createType(overrideName, typeDefinition, crs, true);
+ }
+
+ return type;
}

0 comments on commit b35d130

Please sign in to comment.
Something went wrong with that request. Please try again.