**** Merged from MCS ****
[mono-project.git] / mcs / class / System.XML / Mono.Xml.Schema / XsdIdentityPath.cs
blob33ce9d19475495bab4b791b29c1def6604557d8a
1 //
2 // Mono.Xml.Schema.XsdIdentityPath.cs
3 //
4 // Author:
5 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
6 //
7 // (C)2003 Atsushi Enomoto
8 //
9 //
10 // These classses represents XML Schema's fake XPath, which
11 // W3C specification calls "XPath", although it is very different
12 // language from XPath.
17 // Permission is hereby granted, free of charge, to any person obtaining
18 // a copy of this software and associated documentation files (the
19 // "Software"), to deal in the Software without restriction, including
20 // without limitation the rights to use, copy, modify, merge, publish,
21 // distribute, sublicense, and/or sell copies of the Software, and to
22 // permit persons to whom the Software is furnished to do so, subject to
23 // the following conditions:
24 //
25 // The above copyright notice and this permission notice shall be
26 // included in all copies or substantial portions of the Software.
27 //
28 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 using System;
37 using System.Collections;
38 using System.Xml;
39 using System.Xml.Schema;
41 namespace Mono.Xml.Schema
43 internal class XsdIdentitySelector
45 XsdIdentityPath [] selectorPaths;
47 ArrayList fields = new ArrayList ();
48 XsdIdentityField [] cachedFields;
50 public XsdIdentitySelector (XmlSchemaXPath selector)
52 selectorPaths = selector.CompiledExpression;
55 public XsdIdentityPath [] Paths {
56 get { return selectorPaths; }
59 public void AddField (XsdIdentityField field)
61 cachedFields = null;
62 fields.Add (field);
65 public XsdIdentityField [] Fields {
66 get {
67 if (cachedFields == null)
68 cachedFields = fields.ToArray (typeof (XsdIdentityField)) as XsdIdentityField [];
69 return cachedFields;
74 internal class XsdIdentityField
76 XsdIdentityPath [] fieldPaths;
77 int index;
79 public XsdIdentityField (XmlSchemaXPath field, int index)
81 this.index = index;
82 fieldPaths = field.CompiledExpression;
85 public XsdIdentityPath [] Paths {
86 get { return fieldPaths; }
89 public int Index {
90 get { return index; }
94 internal class XsdIdentityPath
96 public XsdIdentityStep [] OrderedSteps;
97 public bool Descendants;
100 internal class XsdIdentityStep
102 public bool IsCurrent;
103 public bool IsAttribute;
104 public bool IsAnyName;
105 public string NsName;
106 public string Name;
107 public string Namespace = "";