public void Reset(XmlSchemaIdentityConstraint source) { this.source = source; this.selector = source.CompiledSelector; this.qname = source.QualifiedName; XmlSchemaKeyref xmlSchemaKeyref = source as XmlSchemaKeyref; if (xmlSchemaKeyref != null) { this.refKeyName = xmlSchemaKeyref.Refer; } this.StartDepth = 0; }
public void Reset (XmlSchemaIdentityConstraint source) { this.source = source; this.selector = source.CompiledSelector; this.qname = source.QualifiedName; XmlSchemaKeyref kr = source as XmlSchemaKeyref; if (kr != null) this.refKeyName = kr.Refer; StartDepth = 0; }
/// <remarks> /// 1. name must be present /// 2. selector and field must be present /// </remarks> internal override int Compile(ValidationEventHandler h, XmlSchema schema) { // If this is already compiled this time, simply skip. if (CompilationId == schema.CompilationId) return 0; if(Name == null) error(h,"Required attribute name must be present"); else if(!XmlSchemaUtil.CheckNCName(this.name)) error(h,"attribute name must be NCName"); else { this.qName = new XmlQualifiedName(Name, AncestorSchema.TargetNamespace); if (schema.NamedIdentities.Contains (qName)) { XmlSchemaIdentityConstraint existing = schema.NamedIdentities [qName] as XmlSchemaIdentityConstraint; error(h, String.Format ("There is already same named identity constraint in this namespace. Existing item is at {0}({1},{2})", existing.SourceUri, existing.LineNumber, existing.LinePosition)); } else schema.NamedIdentities.Add (qName, this); } if(Selector == null) error(h,"selector must be present"); else { Selector.isSelector = true; errorCount += Selector.Compile(h,schema); if (selector.errorCount == 0) compiledSelector = new XsdIdentitySelector (Selector); } if (errorCount > 0) return errorCount; // fatal if(Fields.Count == 0) error(h,"atleast one field value must be present"); else { for (int i = 0; i < Fields.Count; i++) { XmlSchemaXPath field = Fields [i] as XmlSchemaXPath; if(field != null) { errorCount += field.Compile(h,schema); if (field.errorCount == 0) this.compiledSelector.AddField (new XsdIdentityField (field, i)); } else error (h, "Object of type " + Fields [i].GetType() + " is invalid in the Fields Collection"); } } XmlSchemaUtil.CompileID(Id,this,schema.IDCollection,h); this.CompilationId = schema.CompilationId; return errorCount; }