Example #1
0
 private void resolveType(TypeReference typeReference) throws UnresolvableReferenceException {
   if (!typeReference.isResolved()) {
     if (typeReference.isAnonymous()) {
       LOG.logDebug("Inline type...");
       // type is defined inline
       TypeDeclaration type = typeReference.getTypeDeclaration();
       typeReference.resolve();
       if (type instanceof ComplexTypeDeclaration) {
         ComplexTypeDeclaration complexType = (ComplexTypeDeclaration) type;
         ElementDeclaration[] subElements = complexType.getExplicitElements();
         for (int i = 0; i < subElements.length; i++) {
           resolveReferences(subElements[i]);
         }
       }
     } else {
       LOG.logDebug("Resolving reference to type: '" + typeReference.getName() + "'...");
       if (typeReference.getName().isInNamespace(this.targetNamespace)) {
         TypeDeclaration type = typeMap.get(typeReference.getName());
         if (type == null) {
           LOG.logDebug("Cannot be resolved!");
           throw new UndefinedXSDTypeException(
               "Type '" + typeReference.getName() + "' is not a defined type.");
         }
         LOG.logDebug("OK.");
         typeReference.resolve(type);
       } else {
         LOG.logDebug("Skipped (not in target / schema namespace).");
       }
     }
   }
 }
Example #2
0
 @Override
 public String toString() {
   StringBuffer sb = new StringBuffer("XML Schema targetNamespace='");
   sb.append(targetNamespace);
   sb.append("'\n");
   sb.append("\n*** ");
   sb.append(elementMap.size());
   sb.append(" global element declarations ***\n");
   for (ElementDeclaration elemDec : elementMap.values()) {
     sb.append(elemDec.toString(""));
   }
   sb.append("\n*** ");
   sb.append(simpleTypeMap.size());
   sb.append(" global simple type declarations ***\n");
   for (SimpleTypeDeclaration type : simpleTypeMap.values()) {
     sb.append(type.toString(""));
   }
   sb.append("\n*** ");
   sb.append(complexTypeMap.size());
   sb.append(" global complex type declarations ***\n");
   for (ComplexTypeDeclaration type : complexTypeMap.values()) {
     sb.append(type.toString(""));
   }
   return sb.toString();
 }
Example #3
0
 private void resolveReferences(TypeDeclaration typeDeclaration)
     throws UnresolvableReferenceException {
   LOG.logDebug(
       "Resolving references in type declaration '"
           + typeDeclaration.getName().getLocalName()
           + "'.");
   if (typeDeclaration instanceof SimpleTypeDeclaration) {
     LOG.logDebug("SimpleType.");
     SimpleTypeDeclaration simpleType = (SimpleTypeDeclaration) typeDeclaration;
     TypeReference typeReference = simpleType.getRestrictionBaseType();
     if (typeReference != null) {
       LOG.logDebug("restriction base='" + typeReference.getName() + "'");
       try {
         resolveType(typeReference);
       } catch (XMLSchemaException e) {
         throw new UndefinedXSDTypeException(
             "Declaration of type '"
                 + typeDeclaration.getName()
                 + "' derives type '"
                 + typeReference.getName()
                 + "' which is not a defined simple type.");
       }
     }
   } else {
     LOG.logDebug("ComplexType.");
     ComplexTypeDeclaration complexType = (ComplexTypeDeclaration) typeDeclaration;
     TypeReference typeReference = complexType.getExtensionBaseType();
     if (typeReference != null) {
       LOG.logDebug("extension base='" + typeReference.getName() + "'");
       try {
         resolveType(typeReference);
       } catch (XMLSchemaException e) {
         throw new UndefinedXSDTypeException(
             "Declaration of type '"
                 + typeDeclaration.getName()
                 + "' derives type '"
                 + typeReference.getName()
                 + "' which is not a defined complex type.");
       }
     }
     ElementDeclaration[] elements = complexType.getExplicitElements();
     for (int i = 0; i < elements.length; i++) {
       resolveReferences(elements[i]);
     }
   }
 }