コード例 #1
0
        internal XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile)
        {
            int errorCount = 0;

            if (schema != null)
            {
                if (schema.ErrorCount == 0 && compile)
                {
                    schema.Compile(this, nameTable, schemaNames, validationEventHandler, ns, schemaInfo, true);
                    ns = schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace;
                }
                errorCount += schema.ErrorCount;
            }
            else
            {
                errorCount += schemaInfo.ErrorCount;
                ns          = NameTable.Add(ns);
            }
            if (errorCount == 0)
            {
                XmlSchemaCollectionNode node = new XmlSchemaCollectionNode();
                node.NamespaceURI = ns;
                node.SchemaInfo   = schemaInfo;
                node.Schema       = schema;
                Add(ns, node);
                return(schema);
            }
            return(null);
        }
コード例 #2
0
        private XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile, System.Xml.XmlResolver resolver)
        {
            int num = 0;

            if (schema != null)
            {
                if ((schema.ErrorCount == 0) && compile)
                {
                    if (!schema.CompileSchema(this, resolver, schemaInfo, ns, this.validationEventHandler, this.nameTable, true))
                    {
                        num = 1;
                    }
                    ns = (schema.TargetNamespace == null) ? string.Empty : schema.TargetNamespace;
                }
                num += schema.ErrorCount;
            }
            else
            {
                num += schemaInfo.ErrorCount;
                ns   = this.NameTable.Add(ns);
            }
            if (num == 0)
            {
                XmlSchemaCollectionNode node = new XmlSchemaCollectionNode {
                    NamespaceURI = ns,
                    SchemaInfo   = schemaInfo,
                    Schema       = schema
                };
                this.Add(ns, node);
                return(schema);
            }
            return(null);
        }
コード例 #3
0
        private XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile, XmlResolver resolver)
        {
            int errorCount = 0;

            if (schema != null)
            {
                if (schema.ErrorCount == 0 && compile)
                {
                    if (!schema.CompileSchema(this, resolver, schemaInfo, ns, _validationEventHandler, _nameTable, true))
                    {
                        errorCount = 1;
                    }
                    ns = schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace;
                }
                errorCount += schema.ErrorCount;
            }
            else
            {
                errorCount += schemaInfo.ErrorCount;
                //ns = ns == null? string.Empty : NameTable.Add(ns);
                ns = NameTable.Add(ns); //Added without checking for ns == null, since XDR cannot have null namespace
            }
            if (errorCount == 0)
            {
                XmlSchemaCollectionNode node = new XmlSchemaCollectionNode();
                node.NamespaceURI = ns;
                node.SchemaInfo   = schemaInfo;
                node.Schema       = schema;
                Add(ns, node);
                return(schema);
            }
            return(null);
        }
コード例 #4
0
 /// <summary>
 /// Looks up the schema by its associated namespace URI
 /// </summary>
 public XmlSchema this[string ns]
 {
     get
     {
         XmlSchemaCollectionNode node = (XmlSchemaCollectionNode)_collection[(ns != null) ? ns : string.Empty];
         return((node != null) ? node.Schema : null);
     }
 }
コード例 #5
0
 private void AddNonThreadSafe(string ns, XmlSchemaCollectionNode node)
 {
     if (_collection[ns] != null)
     {
         _collection.Remove(ns);
     }
     _collection.Add(ns, node);
 }
コード例 #6
0
        internal SchemaInfo GetSchemaInfo(string ns)
        {
            XmlSchemaCollectionNode node = (XmlSchemaCollectionNode)this.collection[(ns != null) ? ns : string.Empty];

            if (node == null)
            {
                return(null);
            }
            return(node.SchemaInfo);
        }
コード例 #7
0
 public XmlSchema this[string ns]
 {
     get
     {
         XmlSchemaCollectionNode node = (XmlSchemaCollectionNode)this.collection[(ns != null) ? ns : string.Empty];
         if (node == null)
         {
             return(null);
         }
         return(node.Schema);
     }
 }
コード例 #8
0
 private void Add(string ns, XmlSchemaCollectionNode node)
 {
     if (_isThreadSafe)
     {
         lock (_wLock)
         {
             AddNonThreadSafe(ns, node);
         }
     }
     else
     {
         AddNonThreadSafe(ns, node);
     }
 }
コード例 #9
0
 public void Add(XmlSchemaCollection schema)
 {
     if (schema == null)
     {
         throw new ArgumentNullException("schema");
     }
     if (this != schema)
     {
         IDictionaryEnumerator enumerator = schema.collection.GetEnumerator();
         while (enumerator.MoveNext())
         {
             XmlSchemaCollectionNode node = (XmlSchemaCollectionNode)enumerator.Value;
             this.Add(node.NamespaceURI, node);
         }
     }
 }
コード例 #10
0
        /// <summary>
        /// Adds all the namespaces defined in the given collection
        /// (including their associated schemas) to this collection.
        /// </summary>
        public void Add(XmlSchemaCollection schema)
        {
            ArgumentNullException.ThrowIfNull(schema);

            if (this == schema)
            {
                return;
            }
            IDictionaryEnumerator enumerator = schema._collection.GetEnumerator();

            while (enumerator.MoveNext())
            {
                XmlSchemaCollectionNode node = (XmlSchemaCollectionNode)enumerator.Value !;
                Add(node !.NamespaceURI !, node);
            }
        }
コード例 #11
0
        /// <summary>
        /// Adds all the namespaces defined in the given collection
        /// (including their associated schemas) to this collection.
        /// </summary>
        public void Add(XmlSchemaCollection schema)
        {
            if (schema == null)
            {
                throw new ArgumentNullException(nameof(schema));
            }
            if (this == schema)
            {
                return;
            }
            IDictionaryEnumerator enumerator = schema._collection.GetEnumerator();

            while (enumerator.MoveNext())
            {
                XmlSchemaCollectionNode node = (XmlSchemaCollectionNode)enumerator.Value;
                Add(node.NamespaceURI, node);
            }
        }
コード例 #12
0
 private void Add(string ns, XmlSchemaCollectionNode node)
 {
     if (isThreadSafe)
     {
         wLock.AcquireWriterLock(timeout);
     }
     try {
         if (collection[ns] != null)
         {
             collection.Remove(ns);
         }
         collection.Add(ns, node);
     }
     finally {
         if (isThreadSafe)
         {
             wLock.ReleaseWriterLock();
         }
     }
 }
コード例 #13
0
ファイル: xmlschemacollection.cs プロジェクト: ArildF/masters
 internal XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile) {
     int errorCount = 0;
     if (schema != null) {
         if (schema.ErrorCount == 0 && compile) {
             schema.Compile(this, nameTable, schemaNames, validationEventHandler, ns, schemaInfo, true);
             ns = schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace;
         }
         errorCount += schema.ErrorCount;
     } 
     else {
         errorCount += schemaInfo.ErrorCount;
         ns = NameTable.Add(ns);
     }
     if (errorCount == 0) {
         XmlSchemaCollectionNode node = new XmlSchemaCollectionNode();
         node.NamespaceURI = ns;
         node.SchemaInfo = schemaInfo; 
         node.Schema = schema; 
         Add(ns, node);
         return schema;
     }
     return null;
 }
コード例 #14
0
ファイル: XmlSchemaCollection.cs プロジェクト: dotnet/corefx
 private void Add(string ns, XmlSchemaCollectionNode node)
 {
     if (_isThreadSafe)
     {
         lock (_wLock)
         {
             AddNonThreadSafe(ns, node);
         }
     }
     else
     {
         AddNonThreadSafe(ns, node);
     }
 }
コード例 #15
0
ファイル: XmlSchemaCollection.cs プロジェクト: dotnet/corefx
 private void AddNonThreadSafe(string ns, XmlSchemaCollectionNode node)
 {
     if (_collection[ns] != null)
         _collection.Remove(ns);
     _collection.Add(ns, node);
 }
コード例 #16
0
        internal SchemaInfo GetSchemaInfo(string ns)
        {
            XmlSchemaCollectionNode node = (XmlSchemaCollectionNode)_collection[(ns != null) ? ns : string.Empty];

            return((node != null) ? node.SchemaInfo : null);
        }
 private XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile, System.Xml.XmlResolver resolver)
 {
     int num = 0;
     if (schema != null)
     {
         if ((schema.ErrorCount == 0) && compile)
         {
             if (!schema.CompileSchema(this, resolver, schemaInfo, ns, this.validationEventHandler, this.nameTable, true))
             {
                 num = 1;
             }
             ns = (schema.TargetNamespace == null) ? string.Empty : schema.TargetNamespace;
         }
         num += schema.ErrorCount;
     }
     else
     {
         num += schemaInfo.ErrorCount;
         ns = this.NameTable.Add(ns);
     }
     if (num == 0)
     {
         XmlSchemaCollectionNode node = new XmlSchemaCollectionNode {
             NamespaceURI = ns,
             SchemaInfo = schemaInfo,
             Schema = schema
         };
         this.Add(ns, node);
         return schema;
     }
     return null;
 }
コード例 #18
0
        private XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile, XmlResolver resolver) {
            int errorCount = 0;
            if (schema != null) {
                if (schema.ErrorCount == 0 && compile) {
					if (!schema.CompileSchema(this, resolver, schemaInfo, ns, validationEventHandler, nameTable, true)) {
						errorCount = 1;
					}
					ns = schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace;
                }
				errorCount += schema.ErrorCount;
            } 
            else {
                errorCount += schemaInfo.ErrorCount;
                //ns = ns == null? string.Empty : NameTable.Add(ns);
                ns = NameTable.Add(ns); //Added without checking for ns == null, since XDR cannot have null namespace
            }
            if (errorCount == 0) {
                XmlSchemaCollectionNode node = new XmlSchemaCollectionNode();
                node.NamespaceURI = ns;
                node.SchemaInfo = schemaInfo; 
				node.Schema = schema; 
                Add(ns, node);
                return schema;
            }
            return null;
        }
コード例 #19
0
        private ValidationType DetectValidationType()
        {
            //Type not yet detected : Check in Schema Collection
            if (reader.Schemas != null && reader.Schemas.Count > 0)
            {
                XmlSchemaCollectionEnumerator enumerator = reader.Schemas.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    XmlSchemaCollectionNode node = enumerator.CurrentNode !;
                    SchemaInfo schemaInfo        = node.SchemaInfo !;
                    if (schemaInfo.SchemaType == SchemaType.XSD)
                    {
                        return(ValidationType.Schema);
                    }
                    else if (schemaInfo.SchemaType == SchemaType.XDR)
                    {
                        return(ValidationType.XDR);
                    }
                }
            }

            if (reader.NodeType == XmlNodeType.Element)
            {
                SchemaType schemaType = SchemaNames.SchemaTypeFromRoot(reader.LocalName, reader.NamespaceURI);
                if (schemaType == SchemaType.XSD)
                {
                    return(ValidationType.Schema);
                }
                else if (schemaType == SchemaType.XDR)
                {
                    return(ValidationType.XDR);
                }
                else
                {
                    int count = reader.AttributeCount;
                    for (int i = 0; i < count; i++)
                    {
                        reader.MoveToAttribute(i);
                        string objectNs   = reader.NamespaceURI;
                        string objectName = reader.LocalName;
                        if (Ref.Equal(objectNs, SchemaNames.NsXmlNs))
                        {
                            if (XdrBuilder.IsXdrSchema(reader.Value))
                            {
                                reader.MoveToElement();
                                return(ValidationType.XDR);
                            }
                        }
                        else if (Ref.Equal(objectNs, SchemaNames.NsXsi))
                        {
                            reader.MoveToElement();
                            return(ValidationType.Schema);
                        }
                        else if (Ref.Equal(objectNs, SchemaNames.QnDtDt.Namespace) && Ref.Equal(objectName, SchemaNames.QnDtDt.Name))
                        {
                            reader.SchemaTypeObject = XmlSchemaDatatype.FromXdrName(reader.Value);
                            reader.MoveToElement();
                            return(ValidationType.XDR);
                        }
                    } //end of for
                    if (count > 0)
                    {
                        reader.MoveToElement();
                    }
                }
            }
            return(ValidationType.Auto);
        }
コード例 #20
0
 private void Add(string ns, XmlSchemaCollectionNode node) {
     if (isThreadSafe)
         wLock.AcquireWriterLock(timeout);           
     try {
         if (collection[ns] != null)
             collection.Remove(ns);
         collection.Add(ns, node);    
     }
     finally {
         if (isThreadSafe)
             wLock.ReleaseWriterLock();                      
     }
 }