2 // Commons.Xml.Relaxng.Derivative.RdpNameClasses.cs
5 // Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
7 // 2003 Atsushi Enomoto "No rights reserved."
9 // Copyright (c) 2004 Novell Inc.
10 // All rights reserved
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 namespace Commons
.Xml
.Relaxng
.Derivative
39 public enum RdpNameClassType
50 public abstract class RdpNameClass
52 public abstract RdpNameClassType NameClassType { get; }
53 public abstract bool Contains (string name
, string ns
);
56 public class RdpAnyName
: RdpNameClass
58 static RdpAnyName instance
;
61 instance
= new RdpAnyName ();
64 public static RdpAnyName Instance
{
65 get { return instance; }
68 private RdpAnyName () {}
70 public override RdpNameClassType NameClassType
{
71 get { return RdpNameClassType.AnyName; }
74 public override bool Contains (string name
, string ns
)
80 public class RdpAnyNameExcept
: RdpNameClass
84 public RdpAnyNameExcept (RdpNameClass except
)
89 public override RdpNameClassType NameClassType
{
90 get { return RdpNameClassType.AnyNameExcept; }
93 public RdpNameClass ExceptNameClass
{
94 get { return except; }
97 public override bool Contains (string name
, string ns
)
99 return (except
== null) || !except
.Contains (name
, ns
);
103 public class RdpNsName
: RdpNameClass
107 public RdpNsName (string ns
)
112 public override RdpNameClassType NameClassType
{
113 get { return RdpNameClassType.NsName; }
116 public string NamespaceURI
{
120 public override bool Contains (string name
, string ns
)
122 return NamespaceURI
== ns
;
126 public class RdpNsNameExcept
: RdpNsName
131 public RdpNsNameExcept (string ns
, RdpNameClass except
)
135 this.except
= except
;
138 public override RdpNameClassType NameClassType
{
139 get { return RdpNameClassType.NsNameExcept; }
142 public RdpNameClass ExceptNameClass
{
143 get { return except; }
146 public override bool Contains (string name
, string ns
)
148 return this.ns
== ns
&&
149 (except
== null || !except
.Contains (name
, ns
));
153 public class RdpName
: RdpNameClass
158 public RdpName (string local
, string ns
)
164 public override RdpNameClassType NameClassType
{
165 get { return RdpNameClassType.Name; }
168 public string NamespaceURI
{
172 public string LocalName
{
173 get { return local; }
176 public override bool Contains (string name
, string ns
)
178 return this.ns
== ns
&& this.local
== name
;
182 public class RdpNameClassChoice
: RdpNameClass
187 public RdpNameClassChoice (RdpNameClass l
, RdpNameClass r
)
193 public override RdpNameClassType NameClassType
{
194 get { return RdpNameClassType.NameClassChoice; }
197 public RdpNameClass LValue
{
201 public RdpNameClass RValue
{
205 public override bool Contains (string name
, string ns
)
207 return l
.Contains (name
, ns
) || r
.Contains (name
, ns
);