상속: XMLSchema
예제 #1
0
        internal void ReadXSDSchema(XmlReader reader, bool denyResolving) {
            XmlSchemaSet sSet = new XmlSchemaSet();
            while (reader.LocalName == Keywords.XSD_SCHEMA && reader.NamespaceURI==Keywords.XSDNS) {
                XmlSchema s = XmlSchema.Read(reader, null);
                sSet.Add(s);
                //read the end tag
                ReadEndElement(reader);
            }
            sSet.Compile();

            XSDSchema schema = new XSDSchema();
            schema.LoadSchema(sSet, this);
        }
 internal void InferSchema(XmlDocument xdoc, string[] excludedNamespaces, XmlReadMode mode)
 {
     IntPtr ptr;
     Bid.ScopeEnter(out ptr, "<ds.DataSet.InferSchema|INFO> %d#, mode=%d{ds.XmlReadMode}\n", this.ObjectID, (int) mode);
     try
     {
         string namespaceURI = xdoc.DocumentElement.NamespaceURI;
         if (excludedNamespaces == null)
         {
             excludedNamespaces = new string[0];
         }
         XmlNodeReader instanceDocument = new XmlIgnoreNamespaceReader(xdoc, excludedNamespaces);
         XmlSchemaInference inference = new XmlSchemaInference {
             Occurrence = XmlSchemaInference.InferenceOption.Relaxed
         };
         if (mode == XmlReadMode.InferTypedSchema)
         {
             inference.TypeInference = XmlSchemaInference.InferenceOption.Restricted;
         }
         else
         {
             inference.TypeInference = XmlSchemaInference.InferenceOption.Relaxed;
         }
         XmlSchemaSet schemaSet = inference.InferSchema(instanceDocument);
         schemaSet.Compile();
         XSDSchema schema = new XSDSchema {
             FromInference = true
         };
         try
         {
             schema.LoadSchema(schemaSet, this);
         }
         finally
         {
             schema.FromInference = false;
         }
     }
     finally
     {
         Bid.ScopeLeave(ref ptr);
     }
 }
예제 #3
0
        internal void ReadXSDSchema(XmlReader reader, bool denyResolving) {
            XmlSchemaSet sSet = new XmlSchemaSet();

            int schemaFragmentCount = 1;
            //read from current schmema element
            if (reader.LocalName == Keywords.XSD_SCHEMA && reader.NamespaceURI == Keywords.XSDNS) {
                if (reader.HasAttributes) {
                    string attribValue = reader.GetAttribute(Keywords.MSD_FRAGMENTCOUNT, Keywords.MSDNS); // this must not move the position
                    if (!Common.ADP.IsEmpty(attribValue)) {
                        schemaFragmentCount = int.Parse(attribValue, null);
                    }
                }
            }

            while (reader.LocalName == Keywords.XSD_SCHEMA && reader.NamespaceURI == Keywords.XSDNS) {
                XmlSchema s = XmlSchema.Read(reader, null);
                sSet.Add(s);
                //read the end tag
                ReadEndElement(reader);

                if (--schemaFragmentCount > 0) {
                    MoveToElement(reader);
                }
                while (reader.NodeType == XmlNodeType.Whitespace) {
                    reader.Skip();
                }
            }
            sSet.Compile();
            XSDSchema schema = new XSDSchema();
            schema.LoadSchema(sSet, this);
        }
예제 #4
0
        internal void InferSchema(XmlDocument xdoc, string[] excludedNamespaces, XmlReadMode mode) {
            IntPtr hscp;
            Bid.ScopeEnter(out hscp, "<ds.DataSet.InferSchema|INFO> %d#, mode=%d{ds.XmlReadMode}\n", ObjectID, (int)mode);
            try {
                string ns = xdoc.DocumentElement.NamespaceURI;
                if (null == excludedNamespaces) {
                    excludedNamespaces = new string[0];
                }
                XmlNodeReader xnr = new XmlIgnoreNamespaceReader(xdoc, excludedNamespaces);
                System.Xml.Schema.XmlSchemaInference infer = new System.Xml.Schema.XmlSchemaInference();

                infer.Occurrence = XmlSchemaInference.InferenceOption.Relaxed;

                if (mode == XmlReadMode.InferTypedSchema)
                    infer.TypeInference = XmlSchemaInference.InferenceOption.Restricted;
                else
                    infer.TypeInference = XmlSchemaInference.InferenceOption.Relaxed;

                XmlSchemaSet schemaSet = infer.InferSchema(xnr);
                schemaSet.Compile();

                XSDSchema schema = new XSDSchema();
                schema.FromInference = true;

                try {
                    schema.LoadSchema(schemaSet, this);
                }
                finally {
                    schema.FromInference = false; // this is always false if you are not calling fron inference
                }
            }
            finally {
                Bid.ScopeLeave(ref hscp);
            }
        }
예제 #5
0
파일: DataSet.cs 프로젝트: dotnet/corefx
        internal void InferSchema(XmlDocument xdoc, string[] excludedNamespaces, XmlReadMode mode)
        {
            long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataSet.InferSchema|INFO> {0}, mode={1}", ObjectID, mode);
            try
            {
                string ns = xdoc.DocumentElement.NamespaceURI;
                if (null == excludedNamespaces)
                {
                    excludedNamespaces = Array.Empty<string>();
                }
                XmlNodeReader xnr = new XmlIgnoreNamespaceReader(xdoc, excludedNamespaces);
                XmlSchemaInference infer = new XmlSchemaInference();

                infer.Occurrence = XmlSchemaInference.InferenceOption.Relaxed;

                infer.TypeInference = (mode == XmlReadMode.InferTypedSchema) ?
                    XmlSchemaInference.InferenceOption.Restricted :
                    XmlSchemaInference.InferenceOption.Relaxed;

                XmlSchemaSet schemaSet = infer.InferSchema(xnr);
                schemaSet.Compile();

                XSDSchema schema = new XSDSchema();
                schema.FromInference = true;

                try
                {
                    schema.LoadSchema(schemaSet, this);
                }
                finally
                {
                    schema.FromInference = false; // this is always false if you are not calling fron inference
                }
            }
            finally
            {
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }