2 // Mono.Xml.Schema.XsdKeyTable.cs
5 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
7 // (C)2003 Atsushi Enomoto
10 using System.Collections;
\r
11 using System.Collections.Specialized;
\r
13 using System.Xml.Schema;
\r
15 namespace Mono.Xml.Schema
\r
17 // Created per constraining element.
\r
18 public class XsdKeyTable
\r
20 private XsdIdentitySelector selector;
\r
21 private XmlSchemaIdentityConstraint source;
\r
22 private XmlQualifiedName qname;
\r
23 private XmlQualifiedName refKeyName;
\r
25 public ArrayList Entries = new ArrayList ();
\r
26 public ArrayList FinishedEntries = new ArrayList ();
\r
28 public int StartDepth;
\r
29 public XsdKeyTable ReferencedKey;
\r
31 public XsdKeyTable (XmlSchemaIdentityConstraint source, XmlReader reader)
\r
33 Reset (source, reader);
\r
36 public XmlQualifiedName QualifiedName {
\r
37 get { return qname; }
\r
40 public XmlQualifiedName RefKeyName {
\r
41 get { return refKeyName; }
\r
44 public XmlSchemaIdentityConstraint SourceSchemaIdentity {
\r
45 get { return source; }
\r
48 public XsdIdentitySelector Selector {
\r
49 get { return selector; }
\r
52 public void Reset (XmlSchemaIdentityConstraint source, XmlReader reader)
\r
54 this.source = source;
\r
55 this.selector = source.CompiledSelector;
\r
56 this.qname = source.QualifiedName;
\r
57 XmlSchemaKeyref kr = source as XmlSchemaKeyref;
\r
59 this.refKeyName = kr.Refer;
\r
63 // In this method, attributes are ignored.
\r
64 public XsdIdentityPath SelectorMatches (ArrayList qnameStack, XmlReader reader)
\r
66 foreach (XsdIdentityPath path in Selector.Paths) {
\r
68 if (reader.Depth == this.StartDepth) {
\r
69 if (path.OrderedSteps.Length == 0)
\r
74 // It does not hit as yet (too shallow to hit).
\r
75 if (reader.Depth - this.StartDepth < path.OrderedSteps.Length - 1)
\r
78 int iter = path.OrderedSteps.Length;
\r
79 if (path.OrderedSteps [iter-1].IsAttribute)
\r
82 if (path.Descendants && reader.Depth < this.StartDepth + iter)
\r
84 else if (!path.Descendants && reader.Depth != this.StartDepth + iter)
\r
89 XsdIdentityStep step;
\r
90 for (int x = 0; x <= iter; x++, iter--) {
\r
91 step = path.OrderedSteps [iter - x];
\r
94 XmlQualifiedName qname = (XmlQualifiedName) qnameStack [qnameStack.Count - x - 1];
\r
95 if (step.NsName != null && qname.Namespace == step.NsName)
\r
97 if (step.Name == qname.Name && step.Namespace == qname.Namespace)
\r
102 if (iter >= 0) // i.e. did not match against the path.
\r