}
} else {
// check for reference to a mapped class
StructureElement structure = (StructureElement)comp;
TemplateElementBase templ = structure.getEffectiveMapping();
if (! (templ instanceof MappingElement)) {
// unknown content, leave it to user to fill in details
if (only) {
addComment(egroup, " Replace \"any\" with details of " +
"content to complete schema ");
addChildElement(egroup, "any");
} else {
addComment(egroup, " No mapping for structure at " +
ValidationException.describe(structure) + " ");
addComment(egroup,
" Fill in details of content here to complete schema ");
}
} else {
MappingElementBase mapping = (MappingElementBase)templ;
if (mapping.isAbstract()) {
// check name to be used for instance of type
String ename = structure.getName();
if (ename == null) {
ename = mapping.getName();
}
if (ename == null) {
// no schema equivalent, embed definition directly
addComment(egroup, "No schema representation for " +
"directly-embedded type, inlining definition");
addComment(egroup, "Add element name to structure at " +
ValidationException.describe(structure) +
" to avoid inlining");
defineList(mapping.children(), egroup, agroup, false);
} else {
// handle abstract mapping element as reference to type
Element element = addChildElement(egroup, "element");
String tname = simpleClassName(mapping.getClassName());
if (element.getPrefix() == null) {
tname = "tns:" + tname;
}
element.setAttribute("type", tname);
String name = structure.getName();
if (name == null) {
name = mapping.getName();
}
element.setAttribute("name", name);
if (structure.isOptional()) {
element.setAttribute("minOccurs", "0");
}
}
} else {
// concrete mapping, check for name overridden
String sname = structure.getName();
String mname = mapping.getName();
if (sname != null && !sname.equals(mname)) {
// inline definition for overridden name
addComment(egroup, "No schema representation for " +
"element reference with different name, inlining " +
"definition");
addComment(egroup,
"Remove name on mapping reference at " +
ValidationException.describe(structure) +
" to avoid inlining");
defineList(mapping.children(), egroup, agroup, false);
} else {
// use element reference for concrete mapping
Element element = addChildElement(egroup, "element");
String tname = simpleClassName(mapping.getClassName());
if (element.getPrefix() == null) {
tname = "tns:" + tname;
}
element.setAttribute("ref", tname);
if (structure.isOptional()) {
element.setAttribute("minOccurs", "0");
}
}
}