protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
LocalElement e = parent.element();
QName tn = t.getTagName();
NonElement target = t.getTarget();
if (canBeDirectElementRef(t,tn) || ((!tn.getNamespaceURI().equals(uri) && tn.getNamespaceURI().length()>0) &&
(!((target instanceof ClassInfo) && (target.getTypeName() == null))))) { // see Issue 517
e.ref(tn);
} else {
e.name(tn.getLocalPart());
writeTypeRef(e,t, "type");
elementFormDefault.writeForm(e,tn);