private void Init(XsdKeyTable keyseq, int depth, IXmlLineInfo li) { this.OwnerSequence = keyseq; this.KeyFields = new XsdKeyEntryFieldCollection(); for (int i = 0; i < keyseq.Selector.Fields.Length; i++) { this.KeyFields.Add(new XsdKeyEntryField(this, keyseq.Selector.Fields[i])); } this.StartDepth = depth; if (li != null && li.HasLineInfo()) { this.SelectorHasLineInfo = true; this.SelectorLineNumber = li.LineNumber; this.SelectorLinePosition = li.LinePosition; } }
private void Init (XsdKeyTable keyseq, int depth, IXmlLineInfo li) { OwnerSequence = keyseq; KeyFields = new XsdKeyEntryFieldCollection (); for (int i = 0; i < keyseq.Selector.Fields.Length; i++) KeyFields.Add (new XsdKeyEntryField (this, keyseq.Selector.Fields [i])); StartDepth = depth; if (li != null) { if (li.HasLineInfo ()) { this.SelectorHasLineInfo = true; this.SelectorLineNumber = li.LineNumber; this.SelectorLinePosition = li.LinePosition; } } }
public XsdKeyEntry ( XsdKeyTable keyseq, int depth, IXmlLineInfo li) { Init (keyseq, depth, li); }
private void EndKeyrefValidation (XsdKeyTable seq, XmlSchemaIdentityConstraint targetIdent) { for (int i = this.keyTables.Count - 1; i >= 0; i--) { XsdKeyTable target = this.keyTables [i] as XsdKeyTable; if (target.SourceSchemaIdentity != targetIdent) continue; seq.ReferencedKey = target; for (int j = 0; j < seq.FinishedEntries.Count; j++) { XsdKeyEntry entry = (XsdKeyEntry) seq.FinishedEntries [j]; for (int k = 0; k < target.FinishedEntries.Count; k++) { XsdKeyEntry targetEntry = (XsdKeyEntry) target.FinishedEntries [k]; if (entry.CompareIdentity (targetEntry)) { entry.KeyRefFound = true; break; } } } } if (seq.ReferencedKey == null) HandleError ("Target key was not found."); ArrayList errors = null; for (int i = 0; i < seq.FinishedEntries.Count; i++) { XsdKeyEntry entry = (XsdKeyEntry) seq.FinishedEntries [i]; if (!entry.KeyRefFound) { if (errors == null) errors = new ArrayList (); errors.Add (" line " + entry.SelectorLineNumber + ", position " + entry.SelectorLinePosition); } } if (errors != null) HandleError ("Invalid identity constraints were found. Referenced key was not found: " + String.Join (" / ", errors.ToArray (typeof (string)) as string [])); }
private void EndIdentityValidation (XsdKeyTable seq) { ArrayList errors = null; for (int i = 0; i < seq.Entries.Count; i++) { XsdKeyEntry entry = (XsdKeyEntry) seq.Entries [i]; if (entry.KeyFound) continue; if (seq.SourceSchemaIdentity is XmlSchemaKey) { if (errors == null) errors = new ArrayList (); errors.Add ("line " + entry.SelectorLineNumber + "position " + entry.SelectorLinePosition); } } if (errors != null) HandleError ("Invalid identity constraints were found. Key was not found. " + String.Join (", ", errors.ToArray (typeof (string)) as string [])); // If it is keyref, then find reference target XmlSchemaKeyref xsdKeyref = seq.SourceSchemaIdentity as XmlSchemaKeyref; if (xsdKeyref != null) EndKeyrefValidation (seq, xsdKeyref.Target); }
private XsdKeyTable CreateNewKeyTable (XmlSchemaIdentityConstraint ident) { XsdKeyTable seq = new XsdKeyTable (ident); seq.StartDepth = reader.Depth; this.keyTables.Add (seq); return seq; }
private void ValidateEndKeyConstraint (XsdKeyTable seq) { ArrayList errors = new ArrayList (); for (int i = 0; i < seq.Entries.Count; i++) { XsdKeyEntry entry = (XsdKeyEntry) seq.Entries [i]; if (entry.KeyFound) continue; if (seq.SourceSchemaIdentity is XmlSchemaKey) errors.Add ("line " + entry.SelectorLineNumber + "position " + entry.SelectorLinePosition); } if (errors.Count > 0) HandleError ("Invalid identity constraints were found. Key was not found. " + String.Join (", ", errors.ToArray (typeof (string)) as string [])); errors.Clear (); // Find reference target XmlSchemaKeyref xsdKeyref = seq.SourceSchemaIdentity as XmlSchemaKeyref; if (xsdKeyref != null) { for (int i = this.keyTables.Count - 1; i >= 0; i--) { XsdKeyTable target = this.keyTables [i] as XsdKeyTable; if (target.SourceSchemaIdentity == xsdKeyref.Target) { seq.ReferencedKey = target; for (int j = 0; j < seq.FinishedEntries.Count; j++) { XsdKeyEntry entry = (XsdKeyEntry) seq.FinishedEntries [j]; for (int k = 0; k < target.FinishedEntries.Count; k++) { XsdKeyEntry targetEntry = (XsdKeyEntry) target.FinishedEntries [k]; if (entry.CompareIdentity (targetEntry)) { entry.KeyRefFound = true; break; } } } } } if (seq.ReferencedKey == null) HandleError ("Target key was not found."); for (int i = 0; i < seq.FinishedEntries.Count; i++) { XsdKeyEntry entry = (XsdKeyEntry) seq.FinishedEntries [i]; if (!entry.KeyRefFound) errors.Add (" line " + entry.SelectorLineNumber + ", position " + entry.SelectorLinePosition); } if (errors.Count > 0) HandleError ("Invalid identity constraints were found. Referenced key was not found: " + String.Join (" / ", errors.ToArray (typeof (string)) as string [])); } }
public XsdKeyEntry( XsdKeyTable keyseq, int depth, IXmlLineInfo li) { Init(keyseq, depth, li); }