super.endSelf();
}
protected void createIdentityConstraint() {
final XMLSchemaReader reader = (XMLSchemaReader)this.reader;
IdentityConstraint id;
String name = startTag.getAttribute("name");
if(name==null) {
reader.reportError( XMLSchemaReader.ERR_MISSING_ATTRIBUTE,
startTag.localName, "name" );
return; // recover by ignoring this constraint.
}
Field[] fs = (Field[])fields.toArray( new Field[fields.size()] );
if( startTag.localName.equals("key") )
id = new KeyConstraint( reader.currentSchema.targetNamespace, name, selector, fs );
else
if( startTag.localName.equals("unique") )
id = new UniqueConstraint( reader.currentSchema.targetNamespace, name, selector, fs );
else
if( startTag.localName.equals("keyref") ) {
final String refer = startTag.getAttribute("refer");
if(refer==null) {
reader.reportError( XMLSchemaReader.ERR_MISSING_ATTRIBUTE,
startTag.localName, "refer" );
return; // recover by ignoring this constraint.
}
final String[] qn = reader.splitQName(refer);
if(qn==null) {
reader.reportError( XMLSchemaReader.ERR_UNDECLARED_PREFIX, qn );
return;
}
final KeyRefConstraint keyRef =
new KeyRefConstraint( reader.currentSchema.targetNamespace, name, selector, fs );
id = keyRef;
// back patch "key" field of KeyRefConstraint.
reader.addBackPatchJob( new GrammarReader.BackPatch(){
public State getOwnerState() { return IdentityConstraintState.this; }
public void patch() {
XMLSchemaSchema s = reader.grammar.getByNamespace(qn[0]);
if(s==null) {
reader.reportError( XMLSchemaReader.ERR_UNDEFINED_SCHEMA, qn[0] );
return;
}
IdentityConstraint idc = s.identityConstraints.get(qn[1]);
if(idc==null) {
reader.reportError( XMLSchemaReader.ERR_UNDEFINED_KEY, refer );
return;
}
if(!(idc instanceof KeyConstraint )) {