src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java

Print this page
rev 472 : 8036030: Update JAX-WS RI integration to latest version

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -1068,23 +1068,27 @@
                                     Element te = (Element) t.getTarget();
                                     elemName = te.getElementName();
                                 }
 
                                 Collection<TypeInfo> refs = propInfo.ref();
-                                TypeInfo ti;
-                                if ((refs != null) && (!refs.isEmpty()) && (elemName != null)
-                                        && ((ti = refs.iterator().next()) == null || ti instanceof ClassInfoImpl)) {
-                                    ClassInfoImpl cImpl = (ClassInfoImpl)ti;
-                                    if ((cImpl != null) && (cImpl.getElementName() != null)) {
+                                if ((refs != null) && (!refs.isEmpty()) && (elemName != null)){
+                                    ClassInfoImpl cImpl = null;
+                                    for (TypeInfo ref : refs) {
+                                       if (ref  == null || ref instanceof ClassInfoImpl) {
+                                           if (elemName.equals(((ClassInfoImpl)ref).getElementName())) {
+                                               cImpl = (ClassInfoImpl) ref;
+                                               break;
+                                           }
+                                       }
+                                    }
+                                    if (cImpl != null)
                                         e.ref(new QName(cImpl.getElementName().getNamespaceURI(), tn.getLocalPart()));
-                                    } else {
+                                    else
                                         e.ref(new QName("", tn.getLocalPart()));
-                                    }
-                                } else {
+                                } else
                                     e.ref(tn);
                                 }
-                            }
                         } else {
                             e.name(tn.getLocalPart());
                             writeTypeRef(e,t, "type");
                             elementFormDefault.writeForm(e,tn);
                         }