Summary description for XmlSchemaObject.
 internal XmlSchemaObject AddItem(XmlSchemaObject item, XmlQualifiedName qname, XmlSchemas schemas)
 {
     if (item == null)
     {
         return null;
     }
     if ((qname == null) || qname.IsEmpty)
     {
         return null;
     }
     string str = item.GetType().Name + ":" + qname.ToString();
     ArrayList list = (ArrayList) this.ObjectCache[str];
     if (list == null)
     {
         list = new ArrayList();
         this.ObjectCache[str] = list;
     }
     for (int i = 0; i < list.Count; i++)
     {
         XmlSchemaObject obj2 = (XmlSchemaObject) list[i];
         if (obj2 == item)
         {
             return obj2;
         }
         if (this.Match(obj2, item, true))
         {
             return obj2;
         }
         this.Warnings.Add(Res.GetString("XmlMismatchSchemaObjects", new object[] { item.GetType().Name, qname.Name, qname.Namespace }));
         this.Warnings.Add("DEBUG:Cached item key:\r\n" + ((string) this.looks[obj2]) + "\r\nnew item key:\r\n" + ((string) this.looks[item]));
     }
     list.Add(item);
     return item;
 }
示例#2
1
        protected SymbolEntry AddSymbol(
            XmlQualifiedName qname, XmlSchemaObject schemaObject, string suffix)
        {
            SymbolEntry symbol = new SymbolEntry();
            symbol.xsdNamespace = qname.Namespace;
            symbol.clrNamespace = configSettings.GetClrNamespace(qname.Namespace);
            symbol.symbolName = qname.Name;
            string identifierName = NameGenerator.MakeValidIdentifier(
                symbol.symbolName, this.configSettings.NameMangler2);
            symbol.identifierName = identifierName;
            int id = 0;
            if(symbols.ContainsKey(symbol))
            {
                identifierName = identifierName + suffix;
                symbol.identifierName = identifierName;
                while (symbols.ContainsKey(symbol))
                {
                    id++;
                    symbol.identifierName = identifierName + id.ToString(CultureInfo.InvariantCulture.NumberFormat);
                }
            }
            if(symbol.isNameFixed())
                nFixedNames++;

            symbols.Add(symbol, symbol);
            schemaNameToIdentifiers.Add(schemaObject, symbol.identifierName); //Type vs typeName
            return symbol;
        }
示例#3
1
		public static void AddToTable (XmlSchemaObjectTable table, XmlSchemaObject obj,
			XmlQualifiedName qname, ValidationEventHandler h)
		{
			if (table.Contains (qname)) {
				// FIXME: This logic unexpectedly allows 
				// one redefining item and two or more redefining items.
				// FIXME: redefining item is not simple replacement,
				// but much more complex stuff.
				if (obj.isRedefineChild) {	// take precedence.
					if (obj.redefinedObject != null)
						obj.error (h, String.Format ("Named item {0} was already contained in the schema object table.", qname));
					else
						obj.redefinedObject = table [qname];
					table.Set (qname, obj);
				}
				else if (table [qname].isRedefineChild) {
					if (table [qname].redefinedObject != null)
						obj.error (h, String.Format ("Named item {0} was already contained in the schema object table.", qname));
					else
						table [qname].redefinedObject = obj;
					return;	// never add to the table.
				}
				else if (StrictMsCompliant) {
					table.Set (qname, obj);
				}
				else
					obj.error (h, String.Format ("Named item {0} was already contained in the schema object table. {1}",
					                             qname, "Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation."));
			}
			else
				table.Set (qname, obj);
		}
示例#4
0
		static internal XmlQualifiedName ParseWsdlArrayType(string type, out string dims, XmlSchemaObject parent) {
			string ns;
			string name;

			int nsLen = type.LastIndexOf(':');

			if (nsLen <= 0) {
				ns = "";
			}
			else {
				ns = type.Substring(0, nsLen);
			}
			int nameLen = type.IndexOf('[', nsLen + 1);

			if (nameLen <= nsLen) {
				throw new InvalidOperationException(Res.GetString(Res.XmlInvalidArrayTypeSyntax, type));
			}
			name = type.Substring(nsLen + 1, nameLen - nsLen - 1);
			dims = type.Substring(nameLen);

			// parent is not null only in the case when we used XmlSchema.Read(), 
			// in which case we need to fixup the wsdl:arayType attribute value
			while (parent != null) {
				if (parent.Namespaces != null) {
					string wsdlNs = (string)parent.Namespaces.Namespaces[ns];
					if (wsdlNs != null) {
						ns = wsdlNs;
						break;
					}
				}
				parent = parent.Parent;
			}
			return new XmlQualifiedName(name, ns);
		}
 protected internal override void Read(XmlSchemaObject obj)
 {
     var simpleType = (XmlSchemaSimpleType) obj;
     var restriction = (XmlSchemaSimpleTypeRestriction) simpleType.Content;
     BaseType = restriction.BaseTypeName;
     base.Read(obj);
 }
        public override string ImportSchemaType(
            string name,
            string ns,
            XmlSchemaObject context,
            XmlSchemas schemas,
            XmlSchemaImporter importer,
            CodeCompileUnit compileUnit,
            CodeNamespace mainNamespace,
            CodeGenerationOptions options,
            CodeDomProvider codeProvider)
        {
            if (ns != "http://www.w3.org/2001/XMLSchema")
                return null;

            switch (name)
            {
                case "anyURI":     return "System.Uri"; 
                case "gDay":       return "System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDay";
                case "gMonth":     return "System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonth";
                case "gMonthDay":  return "System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonthDay";
                case "gYear":      return "System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYear"; 
                case "gYearMonth": return "System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYearMonth";
                case "duration":   return "System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDuration"; 
                default: return null;
            }
        }
        private static string GetHelpKeyword(XmlSchemaSet schemaSet, string xmlNamespace, XmlSchemaObject xmlSchemaObject)
        {
            var xmlLastObject = xmlSchemaObject;
            var sb = new StringBuilder();
            while (xmlSchemaObject != null && !(xmlSchemaObject is XmlSchema))
            {
                xmlSchemaObject = ResolveLink(schemaSet, xmlSchemaObject);
                var name = GetName(xmlSchemaObject);
                if (name != null)
                {
                    if (sb.Length > 0)
                        sb.Insert(0, "/");
                    sb.Insert(0, name);
                }

                xmlLastObject = xmlSchemaObject;
                xmlSchemaObject = xmlSchemaObject.Parent;
            }

            if (xmlLastObject is XmlSchemaGroup)
                sb.Insert(0, "#G/");
            else if (xmlLastObject is XmlSchemaAttributeGroup)
                sb.Insert(0, "#AG/");
            else if (xmlLastObject is XmlSchemaSimpleType || xmlLastObject is XmlSchemaComplexType)
                sb.Insert(0, "#T/");
            else
                sb.Insert(0, "#E/");

            sb.Insert(0, xmlNamespace ?? String.Empty);
            return sb.ToString();
        }
 internal void AddRef(ArrayList list, XmlSchemaObject o)
 {
     if (((((o != null) && !this.schemas.IsReference(o)) && (o.Parent is XmlSchema)) && (((XmlSchema) o.Parent).TargetNamespace != "http://www.w3.org/2001/XMLSchema")) && !list.Contains(o))
     {
         list.Add(o);
     }
 }
 private void AddSchemaItem(XmlSchemaObject item, string ns, string referencingNs)
 {
     XmlSchema schema = this.schemas[ns];
     if (schema == null)
     {
         schema = this.AddSchema(ns);
     }
     if (item is XmlSchemaElement)
     {
         XmlSchemaElement element = (XmlSchemaElement) item;
         if (element.Form == XmlSchemaForm.Unqualified)
         {
             throw new InvalidOperationException(Res.GetString("XmlIllegalForm", new object[] { element.Name }));
         }
         element.Form = XmlSchemaForm.None;
     }
     else if (item is XmlSchemaAttribute)
     {
         XmlSchemaAttribute attribute = (XmlSchemaAttribute) item;
         if (attribute.Form == XmlSchemaForm.Unqualified)
         {
             throw new InvalidOperationException(Res.GetString("XmlIllegalForm", new object[] { attribute.Name }));
         }
         attribute.Form = XmlSchemaForm.None;
     }
     schema.Items.Add(item);
     this.AddSchemaImport(ns, referencingNs);
 }
        //public override string ImportSchemaType(
        //    string name, 
        //    string ns, 
        //    XmlSchemaObject context, 
        //    XmlSchemas schemas, 
        //    XmlSchemaImporter importer,
        //    CodeCompileUnit compileUnit, 
        //    CodeNamespace mainNamespace, 
        //    CodeGenerationOptions options, 
        //    CodeDomProvider codeProvider)
        //{

        //    XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) schemas.Find(new XmlQualifiedName(name, ns), typeof(XmlSchemaSimpleType));
        //    return ImportSchemaType(
        //        simpleType, 
        //        context, 
        //        schemas, 
        //        importer, 
        //        compileUnit, 
        //        mainNamespace, 
        //        options, 
        //        codeProvider);
        //}

        public override string ImportSchemaType(
            XmlSchemaType type, 
            XmlSchemaObject context, 
            XmlSchemas schemas, 
            XmlSchemaImporter importer,
            CodeCompileUnit compileUnit, 
            CodeNamespace mainNamespace, 
            CodeGenerationOptions options, 
            CodeDomProvider codeProvider)
        {

            XmlSchemaAnnotated annotatedType  = type as XmlSchemaAnnotated;
            if (annotatedType == null)
                return null;

            if (annotatedType.Annotation == null)
                return null;

            // create the comments and add them to the hash table under the namespace of the object
            CreateComments(annotatedType);

            //mainNamespace.Types.

            return null;

        }
        public DocumentationInfo GetObjectDocumentationInfo(XmlSchemaObject obj)
        {
            var documentationInfo = InternalGetDocumentationInfo(obj);
            if (documentationInfo != null)
                return documentationInfo;

            XmlSchemaElement element;
            if (Casting.TryCast(obj, out element))
            {
                if (!element.RefName.IsEmpty)
                    return GetObjectDocumentationInfo(Context.SchemaSetManager.SchemaSet.GlobalElements[element.RefName]);

                if (element.ElementSchemaType != null && Context.Configuration.UseTypeDocumentationForUndocumentedElements)
                    return GetObjectDocumentationInfo(element.ElementSchemaType);
            }

            XmlSchemaAttribute attribute;
            if (Casting.TryCast(obj, out attribute))
            {
                if (!attribute.RefName.IsEmpty)
                    return GetObjectDocumentationInfo(Context.SchemaSetManager.SchemaSet.GlobalAttributes[attribute.RefName]);

                if (attribute.AttributeSchemaType != null && Context.Configuration.UseTypeDocumentationForUndocumentedAttributes)
                    return GetObjectDocumentationInfo(attribute.AttributeSchemaType);
            }

            return null;
        }
 protected internal override void Read(XmlSchemaObject obj)
 {
     var element = (XmlSchemaElement) obj;
     ElementName = element.Name;
     Type = element.SchemaTypeName;
     base.Read(obj);
 }
        private static string GetName(XmlSchemaObject xmlSchemaObject)
        {
            var isGlobal = xmlSchemaObject.Parent is XmlSchema;

            var soAsAttribute = xmlSchemaObject as XmlSchemaAttribute;
            if (soAsAttribute != null)
                if (isGlobal)
                    return soAsAttribute.QualifiedName.Name;
                else
                    return "@" + soAsAttribute.QualifiedName.Name;

            var soAsElement = xmlSchemaObject as XmlSchemaElement;
            if (soAsElement != null)
                return soAsElement.QualifiedName.Name;

            var soAsGroup = xmlSchemaObject as XmlSchemaGroup;
            if (soAsGroup != null)
                return soAsGroup.QualifiedName.Name;

            var soAsAttributeGroup = xmlSchemaObject as XmlSchemaAttributeGroup;
            if (soAsAttributeGroup != null)
                return soAsAttributeGroup.QualifiedName.Name;

            var soAsComplexType = xmlSchemaObject as XmlSchemaComplexType;
            if (soAsComplexType != null && !soAsComplexType.QualifiedName.IsEmpty)
                return soAsComplexType.QualifiedName.Name;

            return null;
        }
		public override string ImportSchemaType(XmlSchemaType type, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider) {
			if (type == null) {
				return null;
			}

			if (importedTypes[type] != null) {
				mainNamespace.Imports.Add(new CodeNamespaceImport(typeof(DataSet).Namespace));
				compileUnit.ReferencedAssemblies.Add("System.Data.dll");
				return (string)importedTypes[type];
			}
			if (!(context is XmlSchemaElement))
				return null;

			if (type is XmlSchemaComplexType) {
				XmlSchemaComplexType ct = (XmlSchemaComplexType)type;
				if (ct.Particle is XmlSchemaSequence) {
					XmlSchemaObjectCollection items = ((XmlSchemaSequence)ct.Particle).Items;
					if (items.Count == 2 && items[0] is XmlSchemaAny && items[1] is XmlSchemaAny) {
						XmlSchemaAny any0 = (XmlSchemaAny)items[0];
						XmlSchemaAny any1 = (XmlSchemaAny)items[1];
						if (any0.Namespace == XmlSchema.Namespace && any1.Namespace == "urn:schemas-microsoft-com:xml-diffgram-v1") {
							string typeName = typeof(DataTable).FullName;
							importedTypes.Add(type, typeName);
							mainNamespace.Imports.Add(new CodeNamespaceImport(typeof(DataTable).Namespace));
							compileUnit.ReferencedAssemblies.Add("System.Data.dll");
							return typeName;
						}
					}
				}
			}
			return null;
		}
示例#15
0
 public string GetSourceCodeAbridged(XmlSchemaObject obj)
 {
     return InternalGetSourceCode(obj, PostProcessingOptions.RemoveAnnotations |
                                       PostProcessingOptions.CollapseElements |
                                       PostProcessingOptions.CollapseAttributes |
                                       PostProcessingOptions.Format);
 }
        public override string ImportSchemaType(
            string name, 
            string ns,
            XmlSchemaObject context, 
            XmlSchemas schemas,
            XmlSchemaImporter importer,
            CodeCompileUnit compileUnit, 
            CodeNamespace codeNamespace,
            CodeGenerationOptions options, 
            CodeDomProvider codeGenerator)
        {

            if (IsBaseType(name, ns))
            {
                return base.ImportSchemaType(name, ns,
                context, schemas,
                importer,
                compileUnit, codeNamespace,
                options, codeGenerator);
            }

            // Add the Namespace, except the first
            for (int i = 1; i < ImportNamespaces.Length; i++)
            {
                string _Import = ImportNamespaces[i];
                codeNamespace.Imports.Add(new CodeNamespaceImport(_Import));
            }

            return name;
        }
        protected internal override void Read(XmlSchemaObject obj)
        {
            var type = (XmlSchemaComplexType) obj;

            if (type.Particle == null)
            {
                throw new InvalidOperationException(string.Format("Missing particle on choice type '{0}'", type.Name));
            }

            var choice = type.Particle as XmlSchemaChoice;

            if (choice == null)
            {
                throw new InvalidOperationException(string.Format("Unexpected particle type '{0}' on choice type '{1}'", type.Particle.GetType(), type.Name));
            }

            MaxOccurs = !string.IsNullOrEmpty(choice.MaxOccursString) ? choice.MaxOccurs : (decimal?) null;

            foreach (var item in choice.Items)
            {
                var element = item as XmlSchemaElement;

                if (element == null)
                {
                    throw new InvalidOperationException(string.Format("Unexpected item type '{0}' on choice type '{1}'", item.GetType(), type.Name));
                }

                var choiceType = new SDataSchemaChoiceItem();
                choiceType.Read(element);
                Types.Add(choiceType);
            }

            base.Read(obj);
        }
示例#18
0
		internal override void SetParent (XmlSchemaObject parent)
		{
			base.SetParent (parent);

			foreach (XmlSchemaObject obj in Items)
				obj.SetParent (this);
		}
示例#19
0
		internal override void SetParent (XmlSchemaObject parent)
		{
			base.SetParent (parent);
			if (Selector != null)
				Selector.SetParent (this);
			foreach (XmlSchemaObject obj in Fields)
				obj.SetParent (this);
		}
		internal override void SetParent (XmlSchemaObject parent)
		{
			base.SetParent (parent);
			if (AnyAttribute != null)
				AnyAttribute.SetParent (this);
			foreach (XmlSchemaObject obj in Attributes)
				obj.SetParent (this);
		}
 void ReadLocation(XmlSchemaObject schemaObject)
 {
     if (schemaObject.SourceUri != null) {
         fileName = schemaObject.SourceUri.Replace("file:///", String.Empty);
     }
     lineNumber = schemaObject.LineNumber;
     linePosition = schemaObject.LinePosition;
 }
示例#22
0
 /// <include file='doc\XmlSchemaException.uex' path='docs/doc[@for="XmlSchemaException.XmlSchemaException5"]/*' />
 protected XmlSchemaException(SerializationInfo info, StreamingContext context) : base(info, context) {
     res                = (string)         info.GetValue("res"  , typeof(string));
     args               = (string[])       info.GetValue("args", typeof(string[]));
     sourceUri          = (string)         info.GetValue("sourceUri", typeof(string));
     lineNumber         = (int)            info.GetValue("lineNumber", typeof(int));
     linePosition       = (int)            info.GetValue("linePosition", typeof(int));
     sourceSchemaObject = (XmlSchemaObject)info.GetValue("sourceSchemaObject", typeof(XmlSchemaObject));
 }
        public static void WriteObsoleteInfo(this MamlWriter writer, Context context, XmlSchemaObject obj)
        {
            var documentationInfo = context.DocumentationManager.GetObjectDocumentationInfo(obj);
            if (documentationInfo == null)
                return;

            writer.WriteObsoleteInfo(context, documentationInfo);
        }
示例#24
0
		internal override void SetParent (XmlSchemaObject parent)
		{
			base.SetParent (parent);
			foreach (XmlSchemaObject i in Items) {
				i.SetParent (this);
				i.isRedefinedComponent = true;
				i.isRedefineChild = true;
			}
		}
        protected internal override void Read(XmlSchemaObject obj)
        {
            if (obj is XmlSchemaElement)
            {
                ElementName = ((XmlSchemaElement) obj).Name;
            }

            base.Read(obj);
        }
        protected internal override void Write(XmlSchemaObject obj)
        {
            if (obj is XmlSchemaElement)
            {
                ((XmlSchemaElement) obj).Name = ElementName;
            }

            base.Write(obj);
        }
 private int FindIndexByValue(XmlSchemaObject xso) {
     int index;
     for(index = 0; index < entries.Count; index++) {
         if((object)entries[index].xso == (object)xso) {
             return index;
         }    
     }
     return -1;
 }
示例#28
0
		protected XmlSchemaException(SerializationInfo info, StreamingContext context)
			: base (info, context)
		{
			this.hasLineInfo = info.GetBoolean ("hasLineInfo");
			this.lineNumber = info.GetInt32 ("lineNumber");
			this.linePosition = info.GetInt32 ("linePosition");
			this.sourceUri = info.GetString ("sourceUri");
			this.sourceObj = info.GetValue ("sourceObj", typeof (XmlSchemaObject)) as XmlSchemaObject;
		}
        protected internal override void Write(XmlSchemaObject obj)
        {
            var element = obj as XmlSchemaElement;
            if (element != null)
            {
                element.Name = ElementName;
            }

            base.Write(obj);
        }
 public override string ImportSchemaType(string name, string xmlNamespace, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider)
 {
     if ((this.m_direct && (context is XmlSchemaElement)) && ((string.CompareOrdinal(this.m_name, name) == 0) && (string.CompareOrdinal(this.m_targetNamespace, xmlNamespace) == 0)))
     {
         compileUnit.ReferencedAssemblies.AddRange(this.m_references);
         mainNamespace.Imports.AddRange(this.m_namespaceImports);
         return this.m_destinationType;
     }
     return null;
 }
示例#31
0
        void ProcessExternal(ValidationEventHandler handler, List <CompiledSchemaMemo> handledUris, XmlResolver resolver, XmlSchemaExternal ext, XmlSchemaSet col)
        {
            if (ext == null)
            {
                error(handler, "Object is not valid in Includes Property of XmlSchema");
                return;
            }

            // The only case we want to handle where the SchemaLocation is null is if the external is an import.
            XmlSchemaImport import = ext as XmlSchemaImport;

            if (ext.SchemaLocation == null && import == null)
            {
                return;
            }

            XmlSchema includedSchema = null;

            if (ext.SchemaLocation != null)
            {
                Stream stream = null;
                string url    = null;
                if (resolver != null)
                {
                    url = GetResolvedUri(resolver, ext.SchemaLocation);
                    foreach (var i in handledUris)
                    {
                        if (i.SourceUri.Equals(url))
                        {
                            // This schema is already handled, so simply skip (otherwise, duplicate definition errrors occur.
                            return;
                        }
                    }
                    handledUris.Add(new CompiledSchemaMemo()
                    {
                        SourceUri = url
                    });
                    try {
                        stream = resolver.GetEntity(new Uri(url), null, typeof(Stream)) as Stream;
                    } catch (Exception) {
                        // LAMESPEC: This is not good way to handle errors, but since we cannot know what kind of XmlResolver will come, so there are no mean to avoid this ugly catch.
                        warn(handler, "Could not resolve schema location URI: " + url);
                        stream = null;
                    }
                }

                // Process redefinition children in advance.
                XmlSchemaRedefine redefine = ext as XmlSchemaRedefine;
                if (redefine != null)
                {
                    for (int j = 0; j < redefine.Items.Count; j++)
                    {
                        XmlSchemaObject redefinedObj = redefine.Items [j];
                        redefinedObj.isRedefinedComponent = true;
                        redefinedObj.isRedefineChild      = true;
                        if (redefinedObj is XmlSchemaType ||
                            redefinedObj is XmlSchemaGroup ||
                            redefinedObj is XmlSchemaAttributeGroup)
                        {
                            compilationItems.Add(redefinedObj);
                        }
                        else
                        {
                            error(handler, "Redefinition is only allowed to simpleType, complexType, group and attributeGroup.");
                        }
                    }
                }

                if (stream == null)
                {
                    // It is missing schema components.
                    missedSubComponents = true;
                    return;
                }
                else
                {
                    XmlTextReader xtr = null;
                    try {
                        xtr            = new XmlTextReader(url, stream, nameTable);
                        includedSchema = XmlSchema.Read(xtr, handler);
                    } finally {
                        if (xtr != null)
                        {
                            xtr.Close();
                        }
                    }
                    includedSchema.schemas = schemas;
                }
                includedSchema.SetParent();
                ext.Schema = includedSchema;
            }

            // Set - actual - target namespace for the included schema * before compilation*.
            if (import != null)
            {
                if (ext.Schema == null && ext.SchemaLocation == null)
                {
                    // if a schema location wasn't specified, check the other schemas we have to see if one of those
                    // is a match.
                    foreach (XmlSchema schema in col.Schemas())
                    {
                        if (schema.TargetNamespace == import.Namespace)
                        {
                            includedSchema         = schema;
                            includedSchema.schemas = schemas;
                            includedSchema.SetParent();
                            ext.Schema = includedSchema;
                            break;
                        }
                    }
                    // handle case where target namespace doesn't exist in schema collection - i.e can't find it at all
                    if (includedSchema == null)
                    {
                        return;
                    }
                }
                else if (includedSchema != null)
                {
                    if (TargetNamespace == includedSchema.TargetNamespace)
                    {
                        error(handler, "Target namespace must be different from that of included schema.");
                        return;
                    }
                    else if (includedSchema.TargetNamespace != import.Namespace)
                    {
                        error(handler, "Attribute namespace and its importing schema's target namespace must be the same.");
                        return;
                    }
                }
            }
            else if (includedSchema != null)
            {
                if (TargetNamespace == null &&
                    includedSchema.TargetNamespace != null)
                {
                    includedSchema.error(handler, String.Format("On {0} element, targetNamespace is required to include a schema which has its own target namespace", ext.GetType().Name));
                    return;
                }
                else if (TargetNamespace != null &&
                         includedSchema.TargetNamespace == null)
                {
                    includedSchema.TargetNamespace = TargetNamespace;
                }
            }

            // Do not compile included schema here.
            if (includedSchema != null)
            {
                AddExternalComponentsTo(includedSchema, compilationItems, handler, handledUris, resolver, col);
            }
        }
示例#32
0
        //Stack<string> m_stack = new Stack<string>();
        //string m_xmlstr;

        /*const int EXTENSION = 1;
         * const int UNION = 2;
         * const int LIST = 4;
         * const int RESTRICTION = 8;
         * const int ATOMIC = 16;
         *
         * const int MINEXCLUSIVE      = 32;
         * const int MININCLUSIVE      = 64;
         * const int MAXEXCLUSIVE      = 128;
         * //const int MAXEXCLUSIVE      = 256;
         * const int EXPLICITTIMEZONE = 256;
         * const int MAXINCLUSIVE      = 512;
         * const int TOTALDIGITS       = 1024;
         * const int FRACTIONDIGITS    = 2048;
         * const int MAXSCALE          = 4096;
         * const int MINSCALE          = 8192;
         * const int LENGTH            = 16384;
         * const int MINLENGTH         = 32768;
         * const int MAXLENGTH         = 65536;
         * const int ENUMERATION       = 131072;
         * const int WHITESPACE        = 262144;
         * const int PATTERN           = 524288;
         * const int ASSERTION         = 1048576;*/

        //private Hashtable hashProcessedElements;

        public string GenerateXmlString(XmlSchemaObject root, XmlSchema xs)
        {
            string tags = null;

            if (root is XmlSchemaComplexType)
            {
                XmlSchemaComplexType ct = root as XmlSchemaComplexType;
                tags += GenerateXmlString(ct.Particle, xs);
            }
            else
            if (root is XmlSchemaElement)
            {
                XmlSchemaElement elem = root as XmlSchemaElement;
                string           tagname;
                if (elem.Name != null)
                {
                    tagname = elem.Name;
                }
                else
                {
                    tagname = elem.RefName.Name;
                }
                //tags += "<" + tagname + ">";
                if (elem.SchemaType is XmlSchemaComplexType)
                {
                    XmlSchemaComplexType ect = elem.SchemaType as XmlSchemaComplexType;
                    tags += "<" + tagname + ">";
                    tags += GenerateXmlString(ect.Particle, xs);
                    int flag = -1;
                    if (SearchNode(xs, tagname) != null)
                    {
                        flag = 1;
                    }
                    else
                    {
                        flag = 0;
                    }

                    tags += "</" + tagname + ">";
                }
                else
                {
                    if (elem.Name == null)
                    {
                        //tags += "<" + elem.RefName.Name + ">";
                        //tags += GenerateXmlString(ect.Particle);
                        //tags += "<" + tagname + ">";
                        tags += GenerateXmlString(SearchNode(xs, elem.RefName.Name), xs);
                        //tags += "</" + tagname + ">";
                        //tags += "</" + elem.RefName.Name + ">";
                    }
                    else
                    {
                        System.Xml.Schema.XmlSchemaObject xso = null;
                        tags += "<" + tagname + ">";
                        //If the default namespaces are changed, the 2nd part of if becomes critical
                        //StackOverflow Otherwise
                        if ((xso = SearchNode(xs, elem.SchemaTypeName.Name)) != null &&
                            !elem.SchemaTypeName.Namespace.StartsWith("http://www.w3.org"))
                        {
                            tags += GenerateXmlString(xso, xs);
                        }
                        tags += "</" + tagname + ">";
                    }
                }
                //tags += "</" + tagname + ">";
            }
            else
            if (root is XmlSchemaGroupBase)
            {
                XmlSchemaGroupBase baseParticle = root as XmlSchemaGroupBase;
                foreach (XmlSchemaParticle subParticle in baseParticle.Items)
                {
                    tags += GenerateXmlString(subParticle, xs);
                }
            }
            return(tags);
        }
示例#33
0
 protected void SendValidationEvent(string code, string msg1, string msg2, XmlSchemaObject source)
 {
     SendValidationEvent(new XmlSchemaException(code, new string[] { msg1, msg2 }, source), XmlSeverityType.Error);
 }
示例#34
0
        internal static XmlSchemaAttributeGroup Read(XmlSchemaReader reader, ValidationEventHandler h)
        {
            XmlSchemaAttributeGroup xmlSchemaAttributeGroup = new XmlSchemaAttributeGroup();

            reader.MoveToElement();
            if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "attributeGroup")
            {
                XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaAttributeGroup.Read, name=" + reader.Name, null);
                reader.SkipToEnd();
                return(null);
            }
            xmlSchemaAttributeGroup.LineNumber   = reader.LineNumber;
            xmlSchemaAttributeGroup.LinePosition = reader.LinePosition;
            xmlSchemaAttributeGroup.SourceUri    = reader.BaseURI;
            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == "id")
                {
                    xmlSchemaAttributeGroup.Id = reader.Value;
                }
                else if (reader.Name == "name")
                {
                    xmlSchemaAttributeGroup.name = reader.Value;
                }
                else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
                {
                    XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for attributeGroup in this context", null);
                }
                else
                {
                    XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaAttributeGroup);
                }
            }
            reader.MoveToElement();
            if (reader.IsEmptyElement)
            {
                return(xmlSchemaAttributeGroup);
            }
            int num = 1;

            while (reader.ReadNextElement())
            {
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (reader.LocalName != "attributeGroup")
                    {
                        XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaAttributeGroup.Read, name=" + reader.Name, null);
                    }
                    break;
                }
                if (num <= 1 && reader.LocalName == "annotation")
                {
                    num = 2;
                    XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h);
                    if (xmlSchemaAnnotation != null)
                    {
                        xmlSchemaAttributeGroup.Annotation = xmlSchemaAnnotation;
                    }
                }
                else
                {
                    if (num <= 2)
                    {
                        if (reader.LocalName == "attribute")
                        {
                            num = 2;
                            XmlSchemaAttribute xmlSchemaAttribute = XmlSchemaAttribute.Read(reader, h);
                            if (xmlSchemaAttribute != null)
                            {
                                xmlSchemaAttributeGroup.Attributes.Add(xmlSchemaAttribute);
                            }
                            continue;
                        }
                        if (reader.LocalName == "attributeGroup")
                        {
                            num = 2;
                            XmlSchemaAttributeGroupRef xmlSchemaAttributeGroupRef = XmlSchemaAttributeGroupRef.Read(reader, h);
                            if (xmlSchemaAttributeGroupRef != null)
                            {
                                xmlSchemaAttributeGroup.attributes.Add(xmlSchemaAttributeGroupRef);
                            }
                            continue;
                        }
                    }
                    if (num <= 3 && reader.LocalName == "anyAttribute")
                    {
                        num = 4;
                        XmlSchemaAnyAttribute xmlSchemaAnyAttribute = XmlSchemaAnyAttribute.Read(reader, h);
                        if (xmlSchemaAnyAttribute != null)
                        {
                            xmlSchemaAttributeGroup.AnyAttribute = xmlSchemaAnyAttribute;
                        }
                    }
                    else
                    {
                        reader.RaiseInvalidElementError();
                    }
                }
            }
            return(xmlSchemaAttributeGroup);
        }
示例#35
0
        protected void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item)
        {
            if (qname.Name.Length == 0)
            {
                return;
            }
            XmlSchemaObject existingObject = (XmlSchemaObject)table[qname];

            if (existingObject != null)
            {
                if (existingObject == item)
                {
                    return;
                }
                string code = Res.Sch_DupGlobalElement;
                if (item is XmlSchemaAttributeGroup)
                {
                    string ns = nameTable.Add(qname.Namespace);
                    if (Ref.Equal(ns, NsXml))   //Check for xml namespace
                    {
                        XmlSchema       schemaForXmlNS        = Preprocessor.GetBuildInSchema();
                        XmlSchemaObject builtInAttributeGroup = schemaForXmlNS.AttributeGroups[qname];
                        if ((object)existingObject == (object)builtInAttributeGroup)
                        {
                            table.Insert(qname, item);
                            return;
                        }
                        else if ((object)item == (object)builtInAttributeGroup)   //trying to overwrite customer's component with built-in, ignore built-in
                        {
                            return;
                        }
                    }
                    else if (IsValidAttributeGroupRedefine(existingObject, item, table))  //check for redefines
                    {
                        return;
                    }
                    code = Res.Sch_DupAttributeGroup;
                }
                else if (item is XmlSchemaAttribute)
                {
                    string ns = nameTable.Add(qname.Namespace);
                    if (Ref.Equal(ns, NsXml))
                    {
                        XmlSchema       schemaForXmlNS   = Preprocessor.GetBuildInSchema();
                        XmlSchemaObject builtInAttribute = schemaForXmlNS.Attributes[qname];
                        if ((object)existingObject == (object)builtInAttribute)   //replace built-in one
                        {
                            table.Insert(qname, item);
                            return;
                        }
                        else if ((object)item == (object)builtInAttribute)   //trying to overwrite customer's component with built-in, ignore built-in
                        {
                            return;
                        }
                    }
                    code = Res.Sch_DupGlobalAttribute;
                }
                else if (item is XmlSchemaSimpleType)
                {
                    if (IsValidTypeRedefine(existingObject, item, table))
                    {
                        return;
                    }
                    code = Res.Sch_DupSimpleType;
                }
                else if (item is XmlSchemaComplexType)
                {
                    if (IsValidTypeRedefine(existingObject, item, table))
                    {
                        return;
                    }
                    code = Res.Sch_DupComplexType;
                }
                else if (item is XmlSchemaGroup)
                {
                    if (IsValidGroupRedefine(existingObject, item, table))  //check for redefines
                    {
                        return;
                    }
                    code = Res.Sch_DupGroup;
                }
                else if (item is XmlSchemaNotation)
                {
                    code = Res.Sch_DupNotation;
                }
                else if (item is XmlSchemaIdentityConstraint)
                {
                    code = Res.Sch_DupIdentityConstraint;
                }
                else
                {
                    Debug.Assert(item is XmlSchemaElement);
                }
                SendValidationEvent(code, qname.ToString(), item);
            }
            else
            {
                table.Add(qname, item);
            }
        }
 public void Reset()
 {
     this.qname = null;
     this.xso   = null;
 }
示例#37
0
 internal void VerifySchemaValid(XmlSchema schema, XmlSchemaObject caller)
 {
     ((DatatypeImplementation)this).VerifySchemaValid(schema, caller);
 }
示例#38
0
 internal XmlSchemaException(string res, string[] args, Exception innerException, string sourceUri, int lineNumber, int linePosition, XmlSchemaObject source) :
     base(CreateMessage(res, args), innerException)
 {
     HResult             = HResults.XmlSchema;
     _res                = res;
     _args               = args;
     _sourceUri          = sourceUri;
     _lineNumber         = lineNumber;
     _linePosition       = linePosition;
     _sourceSchemaObject = source;
 }
 internal void Add(XmlQualifiedName name, XmlSchemaObject value)
 {
     this.table.Add(name, value);
     this.entries.Add(new XmlSchemaObjectEntry(name, value));
 }
 internal XmlSchemaException(string?res, string?arg, XmlSchemaObject source) :
     this(res, new string?[] { arg }, source)
 {
 }
示例#41
0
 internal abstract void VerifySchemaValid(XmlSchemaObjectTable notations, XmlSchemaObject caller);
示例#42
0
 protected void SendValidationEvent(string code, string msg, XmlSchemaObject source, XmlSeverityType severity)
 {
     SendValidationEvent(new XmlSchemaException(code, msg, source), severity);
 }
示例#43
0
 internal XmlSchemaValidationException(string message, XmlSchemaObject sourceObject,
                                       Exception innerException)
     : base(message, sourceObject, innerException)
 {
 }
示例#44
0
        void DoCompile(ValidationEventHandler handler, List <CompiledSchemaMemo> handledUris, XmlSchemaSet col, XmlResolver resolver)
        {
            SetParent();
            CompilationId = col.CompilationId;
            schemas       = col;
            if (!schemas.Contains(this))              // e.g. xs:import
            {
                schemas.Add(this);
            }

            attributeGroups.Clear();
            attributes.Clear();
            elements.Clear();
            groups.Clear();
            notations.Clear();
            schemaTypes.Clear();
            named_identities.Clear();
            ids.Clear();
            compilationItems.Clear();

            //1. Union and List are not allowed in block default
            if (BlockDefault != XmlSchemaDerivationMethod.All)
            {
                if ((BlockDefault & XmlSchemaDerivationMethod.List) != 0)
                {
                    error(handler, "list is not allowed in blockDefault attribute");
                }
                if ((BlockDefault & XmlSchemaDerivationMethod.Union) != 0)
                {
                    error(handler, "union is not allowed in blockDefault attribute");
                }
            }

            //2. Substitution is not allowed in finaldefault.
            if (FinalDefault != XmlSchemaDerivationMethod.All)
            {
                if ((FinalDefault & XmlSchemaDerivationMethod.Substitution) != 0)
                {
                    error(handler, "substitution is not allowed in finalDefault attribute");
                }
            }

            //3. id must be of type ID
            XmlSchemaUtil.CompileID(Id, this, IDCollection, handler);

            //4. targetNamespace should be of type anyURI or absent
            if (TargetNamespace != null)
            {
                if (TargetNamespace.Length == 0)
                {
                    error(handler, "The targetNamespace attribute cannot have have empty string as its value.");
                }

                if (!XmlSchemaUtil.CheckAnyUri(TargetNamespace))
                {
                    error(handler, TargetNamespace + " is not a valid value for targetNamespace attribute of schema");
                }
            }

            //5. version should be of type normalizedString
            if (!XmlSchemaUtil.CheckNormalizedString(Version))
            {
                error(handler, Version + "is not a valid value for version attribute of schema");
            }

            // Compile the content of this schema

            for (int i = 0; i < Items.Count; i++)
            {
                compilationItems.Add(Items [i]);
            }

            // First, we run into inclusion schemas to collect
            // compilation target items into compiledItems.
            for (int i = 0; i < Includes.Count; i++)
            {
                ProcessExternal(handler, handledUris, resolver, Includes [i] as XmlSchemaExternal, col);
            }

            // Compilation phase.
            // At least each Compile() must give unique (qualified) name for each component.
            // It also checks self-resolvable properties correctness.
            // Post compilation schema information contribution is not done here.
            // It should be done by Validate().
            for (int i = 0; i < compilationItems.Count; i++)
            {
                XmlSchemaObject obj = compilationItems [i];
                if (obj is XmlSchemaAnnotation)
                {
                    int numerr = ((XmlSchemaAnnotation)obj).Compile(handler, this);
                    errorCount += numerr;
                }
                else if (obj is XmlSchemaAttribute)
                {
                    XmlSchemaAttribute attr = (XmlSchemaAttribute)obj;
                    int numerr = attr.Compile(handler, this);
                    errorCount += numerr;
                    if (numerr == 0)
                    {
                        XmlSchemaUtil.AddToTable(Attributes, attr, attr.QualifiedName, handler);
                    }
                }
                else if (obj is XmlSchemaAttributeGroup)
                {
                    XmlSchemaAttributeGroup attrgrp = (XmlSchemaAttributeGroup)obj;
                    int numerr = attrgrp.Compile(handler, this);
                    errorCount += numerr;
                    if (numerr == 0)
                    {
                        XmlSchemaUtil.AddToTable(
                            AttributeGroups,
                            attrgrp,
                            attrgrp.QualifiedName,
                            handler);
                    }
                }
                else if (obj is XmlSchemaComplexType)
                {
                    XmlSchemaComplexType ctype = (XmlSchemaComplexType)obj;
                    int numerr = ctype.Compile(handler, this);
                    errorCount += numerr;
                    if (numerr == 0)
                    {
                        XmlSchemaUtil.AddToTable(
                            schemaTypes,
                            ctype,
                            ctype.QualifiedName,
                            handler);
                    }
                }
                else if (obj is XmlSchemaSimpleType)
                {
                    XmlSchemaSimpleType stype = (XmlSchemaSimpleType)obj;
                    stype.islocal = false;                     //This simple type is toplevel
                    int numerr = stype.Compile(handler, this);
                    errorCount += numerr;
                    if (numerr == 0)
                    {
                        XmlSchemaUtil.AddToTable(
                            SchemaTypes,
                            stype,
                            stype.QualifiedName,
                            handler);
                    }
                }
                else if (obj is XmlSchemaElement)
                {
                    XmlSchemaElement elem = (XmlSchemaElement)obj;
                    elem.parentIsSchema = true;
                    int numerr = elem.Compile(handler, this);
                    errorCount += numerr;
                    if (numerr == 0)
                    {
                        XmlSchemaUtil.AddToTable(
                            Elements,
                            elem,
                            elem.QualifiedName,
                            handler);
                    }
                }
                else if (obj is XmlSchemaGroup)
                {
                    XmlSchemaGroup grp    = (XmlSchemaGroup)obj;
                    int            numerr = grp.Compile(handler, this);
                    errorCount += numerr;
                    if (numerr == 0)
                    {
                        XmlSchemaUtil.AddToTable(
                            Groups,
                            grp,
                            grp.QualifiedName,
                            handler);
                    }
                }
                else if (obj is XmlSchemaNotation)
                {
                    XmlSchemaNotation ntn = (XmlSchemaNotation)obj;
                    int numerr            = ntn.Compile(handler, this);
                    errorCount += numerr;
                    if (numerr == 0)
                    {
                        XmlSchemaUtil.AddToTable(
                            Notations,
                            ntn,
                            ntn.QualifiedName,
                            handler);
                    }
                }
                else
                {
                    ValidationHandler.RaiseValidationEvent(
                        handler,
                        null,
                        String.Format("Object of Type {0} is not valid in Item Property of Schema", obj.GetType().Name),
                        null,
                        this,
                        null,
                        XmlSeverityType.Error);
                }
            }
        }
示例#45
0
 internal virtual void SetParent(XmlSchemaObject parent)
 {
     Parent = parent;
 }
示例#46
0
 internal void Add(XmlQualifiedName name, XmlSchemaObject value)
 {
     Debug.Assert(!_table.ContainsKey(name), "XmlSchemaObjectTable.Add: entry already exists");
     _table.Add(name, value);
     _entries.Add(new XmlSchemaObjectEntry(name, value));
 }
 public void Reset()
 {
     this.currentIndex = -1;
     this.currentValue = null;
     this.currentKey   = null;
 }
示例#48
0
 public XmlSchemaObjectEntry(XmlQualifiedName name, XmlSchemaObject value)
 {
     qname = name;
     xso   = value;
 }
 internal XmlSchemaException(string?res, string?[]?args, XmlSchemaObject source) :
     this(res, args, null, source.SourceUri, source.LineNumber, source.LinePosition, source)
 {
 }
        internal static XmlSchemaRedefine Read(XmlSchemaReader reader, ValidationEventHandler h)
        {
            XmlSchemaRedefine xmlSchemaRedefine = new XmlSchemaRedefine();

            reader.MoveToElement();
            if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "redefine")
            {
                XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaRedefine.Read, name=" + reader.Name, null);
                reader.Skip();
                return(null);
            }
            xmlSchemaRedefine.LineNumber   = reader.LineNumber;
            xmlSchemaRedefine.LinePosition = reader.LinePosition;
            xmlSchemaRedefine.SourceUri    = reader.BaseURI;
            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == "id")
                {
                    xmlSchemaRedefine.Id = reader.Value;
                }
                else if (reader.Name == "schemaLocation")
                {
                    xmlSchemaRedefine.SchemaLocation = reader.Value;
                }
                else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
                {
                    XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for redefine", null);
                }
                else
                {
                    XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaRedefine);
                }
            }
            reader.MoveToElement();
            if (reader.IsEmptyElement)
            {
                return(xmlSchemaRedefine);
            }
            while (reader.ReadNextElement())
            {
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (reader.LocalName != "redefine")
                    {
                        XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaRedefine.Read, name=" + reader.Name, null);
                    }
                    break;
                }
                if (reader.LocalName == "annotation")
                {
                    XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h);
                    if (xmlSchemaAnnotation != null)
                    {
                        xmlSchemaRedefine.items.Add(xmlSchemaAnnotation);
                    }
                }
                else if (reader.LocalName == "simpleType")
                {
                    XmlSchemaSimpleType xmlSchemaSimpleType = XmlSchemaSimpleType.Read(reader, h);
                    if (xmlSchemaSimpleType != null)
                    {
                        xmlSchemaRedefine.items.Add(xmlSchemaSimpleType);
                    }
                }
                else if (reader.LocalName == "complexType")
                {
                    XmlSchemaComplexType xmlSchemaComplexType = XmlSchemaComplexType.Read(reader, h);
                    if (xmlSchemaComplexType != null)
                    {
                        xmlSchemaRedefine.items.Add(xmlSchemaComplexType);
                    }
                }
                else if (reader.LocalName == "group")
                {
                    XmlSchemaGroup xmlSchemaGroup = XmlSchemaGroup.Read(reader, h);
                    if (xmlSchemaGroup != null)
                    {
                        xmlSchemaRedefine.items.Add(xmlSchemaGroup);
                    }
                }
                else if (reader.LocalName == "attributeGroup")
                {
                    XmlSchemaAttributeGroup xmlSchemaAttributeGroup = XmlSchemaAttributeGroup.Read(reader, h);
                    if (xmlSchemaAttributeGroup != null)
                    {
                        xmlSchemaRedefine.items.Add(xmlSchemaAttributeGroup);
                    }
                }
                else
                {
                    reader.RaiseInvalidElementError();
                }
            }
            return(xmlSchemaRedefine);
        }
 internal void SetSchemaObject(XmlSchemaObject source)
 {
     _sourceSchemaObject = source;
 }
示例#52
0
 public static void Validate(this XElement source, XmlSchemaObject partialValidationType, XmlSchemaSet schemas, ValidationEventHandler validationEventHandler, bool addSchemaInfo)
 {
     throw new NotImplementedException();
 }
示例#53
0
 internal XmlSchemaValidationException(string res, string[] args, string sourceUri, int lineNumber, int linePosition, XmlSchemaObject source, object sourceNode) :
     base(res, args, null, sourceUri, lineNumber, linePosition, source)
 {
     _sourceNodeObject = sourceNode;
 }
示例#54
0
 public static void Validate(this XAttribute source, XmlSchemaObject partialValidationType, XmlSchemaSet schemas, ValidationEventHandler validationEventHandler)
 {
     Validate(source, partialValidationType, schemas, validationEventHandler, false);
 }
        internal static XmlSchemaAnyAttribute Read(XmlSchemaReader reader, ValidationEventHandler h)
        {
            XmlSchemaAnyAttribute xmlSchemaAnyAttribute = new XmlSchemaAnyAttribute();

            reader.MoveToElement();
            if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "anyAttribute")
            {
                XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaAnyAttribute.Read, name=" + reader.Name, null);
                reader.SkipToEnd();
                return(null);
            }
            xmlSchemaAnyAttribute.LineNumber   = reader.LineNumber;
            xmlSchemaAnyAttribute.LinePosition = reader.LinePosition;
            xmlSchemaAnyAttribute.SourceUri    = reader.BaseURI;
            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == "id")
                {
                    xmlSchemaAnyAttribute.Id = reader.Value;
                }
                else if (reader.Name == "namespace")
                {
                    xmlSchemaAnyAttribute.nameSpace = reader.Value;
                }
                else if (reader.Name == "processContents")
                {
                    Exception ex;
                    xmlSchemaAnyAttribute.processing = XmlSchemaUtil.ReadProcessingAttribute(reader, out ex);
                    if (ex != null)
                    {
                        XmlSchemaObject.error(h, reader.Value + " is not a valid value for processContents", ex);
                    }
                }
                else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
                {
                    XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for anyAttribute", null);
                }
                else
                {
                    XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaAnyAttribute);
                }
            }
            reader.MoveToElement();
            if (reader.IsEmptyElement)
            {
                return(xmlSchemaAnyAttribute);
            }
            int num = 1;

            while (reader.ReadNextElement())
            {
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (reader.LocalName != "anyAttribute")
                    {
                        XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaAnyAttribute.Read, name=" + reader.Name, null);
                    }
                    break;
                }
                if (num <= 1 && reader.LocalName == "annotation")
                {
                    num = 2;
                    XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h);
                    if (xmlSchemaAnnotation != null)
                    {
                        xmlSchemaAnyAttribute.Annotation = xmlSchemaAnnotation;
                    }
                }
                else
                {
                    reader.RaiseInvalidElementError();
                }
            }
            return(xmlSchemaAnyAttribute);
        }
 internal XmlSchemaException(string res, XmlSchemaObject source) :
     this(res, (string[])null, source)
 {
 }
示例#57
0
 public SchemaNamespaceManager(XmlSchemaObject node)
 {
     _node = node;
 }
示例#58
0
 protected void SendValidationEvent(string code, string[] args, Exception innerException, XmlSchemaObject source)
 {
     SendValidationEvent(new XmlSchemaException(code, args, innerException, source.SourceUri, source.LineNumber, source.LinePosition, source), XmlSeverityType.Error);
 }
示例#59
0
 internal XmlSchemaValidationException(string message, int lineNumber, int linePosition,
                                       XmlSchemaObject sourceObject, string sourceUri, Exception innerException)
     : base(message, lineNumber, linePosition, sourceObject, sourceUri, innerException)
 {
 }
        internal SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, XmlSchemaObject partialValidationType, out AttributeMatchState attributeMatchState)
        {
            SchemaAttDef attDef = null;

            attributeMatchState = AttributeMatchState.UndeclaredAttribute;
            if (ed != null)
            {
                attDef = ed.GetAttDef(qname);
                if (attDef != null)
                {
                    attributeMatchState = AttributeMatchState.AttributeFound;
                    return(attDef);
                }
                XmlSchemaAnyAttribute anyAttribute = ed.AnyAttribute;
                if (anyAttribute != null)
                {
                    if (!anyAttribute.NamespaceList.Allows(qname))
                    {
                        attributeMatchState = AttributeMatchState.ProhibitedAnyAttribute;
                        return(attDef);
                    }
                    if (anyAttribute.ProcessContentsCorrect != XmlSchemaContentProcessing.Skip)
                    {
                        if (this.attributeDecls.TryGetValue(qname, out attDef))
                        {
                            if (attDef.Datatype.TypeCode == XmlTypeCode.Id)
                            {
                                attributeMatchState = AttributeMatchState.AnyIdAttributeFound;
                                return(attDef);
                            }
                            attributeMatchState = AttributeMatchState.AttributeFound;
                            return(attDef);
                        }
                        if (anyAttribute.ProcessContentsCorrect == XmlSchemaContentProcessing.Lax)
                        {
                            attributeMatchState = AttributeMatchState.AnyAttributeLax;
                        }
                        return(attDef);
                    }
                    attributeMatchState = AttributeMatchState.AnyAttributeSkip;
                    return(attDef);
                }
                if (ed.ProhibitedAttributes.ContainsKey(qname))
                {
                    attributeMatchState = AttributeMatchState.ProhibitedAttribute;
                }
                return(attDef);
            }
            if (partialValidationType != null)
            {
                XmlSchemaAttribute attribute2 = partialValidationType as XmlSchemaAttribute;
                if (attribute2 != null)
                {
                    if (qname.Equals(attribute2.QualifiedName))
                    {
                        attDef = attribute2.AttDef;
                        attributeMatchState = AttributeMatchState.AttributeFound;
                        return(attDef);
                    }
                    attributeMatchState = AttributeMatchState.AttributeNameMismatch;
                    return(attDef);
                }
                attributeMatchState = AttributeMatchState.ValidateAttributeInvalidCall;
                return(attDef);
            }
            if (this.attributeDecls.TryGetValue(qname, out attDef))
            {
                attributeMatchState = AttributeMatchState.AttributeFound;
                return(attDef);
            }
            attributeMatchState = AttributeMatchState.UndeclaredElementAndAttribute;
            return(attDef);
        }