// the element may be defined locally or globally
element def = getDefinition(ctx.getModel(),ctx);
schema xs = (schema) def.get_owner();
if (isQualified()) {
e = doc.createElementNS(xs.getTargetNamespace(), def.getName());
// if the default ns is undefined use this tns (unprefixed)
// (this element may already be in the default namespace)
String dns = expandPrefix("", xml,null,ctx.getModel());
// use prefixes where there may be unqualified elements and this is qualified
if ((dns==null && (xs.getElementFormDefault().equals("unqualified")))