X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.XML%2FMono.Xml.Schema%2FXsdWildcard.cs;h=e74617150bf7b7024d1674eb00ee3d9d1913f5f6;hb=4d2de5c6abdc30ff973eb5f1987f3e5e52288e8b;hp=ab9c3c8c0baef73333cba5a0784b87d3faa22644;hpb=00e065484e866f3a0349c882f804c4a79a13ee5c;p=mono.git diff --git a/mcs/class/System.XML/Mono.Xml.Schema/XsdWildcard.cs b/mcs/class/System.XML/Mono.Xml.Schema/XsdWildcard.cs index ab9c3c8c0ba..e74617150bf 100644 --- a/mcs/class/System.XML/Mono.Xml.Schema/XsdWildcard.cs +++ b/mcs/class/System.XML/Mono.Xml.Schema/XsdWildcard.cs @@ -1,36 +1,36 @@ -// -// Mono.Xml.Schema.XsdWildcard.cs -// -// Author: -// Atsushi Enomoto (ginga@kit.hi-ho.ne.jp) -// -// (C)2003 Atsushi Enomoto -// -// -// This class represents common part of xs:any and xs:anyAttribute -// -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// +// Mono.Xml.Schema.XsdWildcard.cs +// +// Author: +// Atsushi Enomoto (ginga@kit.hi-ho.ne.jp) +// +// (C)2003 Atsushi Enomoto +// +// +// This class represents common part of xs:any and xs:anyAttribute +// +// + +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// using System; using System.Collections.Specialized; using System.Xml; @@ -49,55 +49,68 @@ namespace Mono.Xml.Schema public XmlSchemaContentProcessing ResolvedProcessing; public string TargetNamespace; + public bool SkipCompile; public bool HasValueAny; public bool HasValueLocal; public bool HasValueOther; public bool HasValueTargetNamespace; public StringCollection ResolvedNamespaces; + void Reset () + { + HasValueAny = false; + HasValueLocal = false; + HasValueOther = false; + HasValueTargetNamespace = false; + ResolvedNamespaces = new StringCollection (); + } + public void Compile (string nss, ValidationEventHandler h, XmlSchema schema) { + if (SkipCompile) + return; // used by XmlSchemaAny.AnyTypeContent. + + Reset (); int nscount = 0; string actualNamespace = nss == null ? "##any" : nss; string[] nslist = XmlSchemaUtil.SplitList(actualNamespace); - ResolvedNamespaces = new StringCollection (); - for (int i = 0; i < nslist.Length; i++) { - string ns = nslist [i]; + for (int i = 0; i < nslist.Length; i++) { + string ns = nslist [i]; switch(ns) { case "##any": - if (HasValueAny) - xsobj.error (h, "Multiple specification of ##any was found."); + if (HasValueAny) + xsobj.error (h, "Multiple specification of ##any was found."); nscount |= 1; - HasValueAny = true; + HasValueAny = true; break; case "##other": - if (HasValueOther) - xsobj.error (h, "Multiple specification of ##other was found."); + if (HasValueOther) + xsobj.error (h, "Multiple specification of ##other was found."); nscount |= 2; - HasValueOther = true; + HasValueOther = true; break; case "##targetNamespace": - if (HasValueTargetNamespace) - xsobj.error (h, "Multiple specification of ##targetNamespace was found."); + if (HasValueTargetNamespace) + xsobj.error (h, "Multiple specification of ##targetNamespace was found."); nscount |= 4; HasValueTargetNamespace = true; break; case "##local": - if (HasValueLocal) - xsobj.error (h, "Multiple specification of ##local was found."); + if (HasValueLocal) + xsobj.error (h, "Multiple specification of ##local was found."); nscount |= 8; - HasValueLocal = true; + HasValueLocal = true; break; default: if(!XmlSchemaUtil.CheckAnyUri(ns)) xsobj.error(h,"the namespace is not a valid anyURI"); - else if (ResolvedNamespaces.Contains (ns)) - xsobj.error (h, "Multiple specification of '" + ns + "' was found."); + else if (ResolvedNamespaces.Contains (ns)) + xsobj.error (h, "Multiple specification of '" + ns + "' was found."); else { nscount |= 16; - ResolvedNamespaces.Add (ns); - } + ResolvedNamespaces.Add (ns); + } break; } } @@ -173,20 +186,20 @@ namespace Mono.Xml.Schema public bool ValidateWildcardAllowsNamespaceName (string ns, ValidationEventHandler h, XmlSchema schema, bool raiseError) { - if (HasValueAny) - return true; - if (HasValueOther && ns != TargetNamespace) - return true; - if (HasValueTargetNamespace && ns == TargetNamespace) - return true; - if (HasValueLocal && ns == "") - return true; - for (int i = 0; i < ResolvedNamespaces.Count; i++) - if (ns == ResolvedNamespaces [i]) - return true; - if (raiseError) - xsobj.error (h, "This wildcard does not allow the namespace: " + ns); - return false; + if (HasValueAny) + return true; + if (HasValueOther && ns != TargetNamespace) + return true; + if (HasValueTargetNamespace && ns == TargetNamespace) + return true; + if (HasValueLocal && ns == "") + return true; + for (int i = 0; i < ResolvedNamespaces.Count; i++) + if (ns == ResolvedNamespaces [i]) + return true; + if (raiseError) + xsobj.error (h, "This wildcard does not allow the namespace: " + ns); + return false; } // 3.10.6 Wildcard Subset