contentType = reader.pool.createValue(
com.sun.msv.datatype.xsd.TokenType.theInstance,
new StringPair("","token"), fixed ); // emulate RELAX NG built-in token type
ElementDeclExp decl;
if( isGlobal() ) {
decl = reader.currentSchema.elementDecls.getOrCreate(name);
if( decl.getElementExp()!=null )
reader.reportError(
new Locator[]{this.location,reader.getDeclaredLocationOf(decl)},
XMLSchemaReader.ERR_DUPLICATE_ELEMENT_DEFINITION,
new Object[]{name} );
} else {
// create a local object.
decl = new ElementDeclExp(reader.currentSchema,null);
}
reader.setDeclaredLocationOf(decl);
ElementDeclExp.XSElementExp exp = decl.new XSElementExp(
new SimpleNameClass(targetNamespace,name), contentType );
// set the body.
decl.setElementExp(exp);
// set identity constraints
exp.identityConstraints.addAll(idcs);
// process the nillable attribute.
String nillable = startTag.getAttribute("nillable");
if( nillable!=null )
decl.isNillable = nillable.equals("true") || nillable.equals("1");
// process the "abstract" attribute.
String abstract_ = startTag.getAttribute("abstract");
decl.setAbstract( "true".equals(abstract_)||"1".equals(abstract_) );
if( abstract_!=null && !BooleanType.theInstance.isValid(abstract_,null) )
// recover by assuming false.
reader.reportError( XMLSchemaReader.ERR_BAD_ATTRIBUTE_VALUE, "abstract", abstract_ );
// TODO: abstract is prohibited for the local element.
// TODO: substitutionGroup is also prohibited for the local element.
String substitutionGroupQName = startTag.getAttribute("substitutionGroup");
if( substitutionGroupQName!=null ) {
String[] r = reader.splitQName(substitutionGroupQName);
if(r==null) {
reader.reportError( XMLSchemaReader.ERR_UNDECLARED_PREFIX, substitutionGroupQName );
// recover by ignoring substitutionGroup.
} else {
// register this declaration to the head elementDecl.
ElementDeclExp head = reader.getOrCreateSchema(r[0]/*uri*/).
elementDecls.getOrCreate(r[1]/*local name*/);
decl.substitutionAffiliation = head;
// before adding this "decl" to "head.substitutions",