當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlValidatingReader.GetSchemaInfo方法代碼示例

本文整理匯總了C#中System.Xml.XmlValidatingReader.GetSchemaInfo方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlValidatingReader.GetSchemaInfo方法的具體用法?C# XmlValidatingReader.GetSchemaInfo怎麽用?C# XmlValidatingReader.GetSchemaInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XmlValidatingReader的用法示例。


在下文中一共展示了XmlValidatingReader.GetSchemaInfo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: LoadDocumentType

        private void LoadDocumentType( XmlValidatingReader vr , XmlDocumentType dtNode ) {
            SchemaInfo schInfo = vr.GetSchemaInfo();
            if (schInfo != null) {
                //set the schema information into the document
                doc.SchemaInformation = schInfo;

                // Notation hashtable
                if (schInfo.Notations != null) {
                    foreach( SchemaNotation scNot in schInfo.Notations.Values ) {
                        dtNode.Notations.SetNamedItem(new XmlNotation( scNot.Name.Name, scNot.Pubid, scNot.SystemLiteral, doc ));
                    }
                }

                // Entity hashtables
                if (schInfo.GeneralEntities != null) {
                    foreach( SchemaEntity scEnt in schInfo.GeneralEntities.Values ) {
                        XmlEntity ent = new XmlEntity( scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, doc );
                        ent.SetBaseURI( scEnt.DeclaredURI );
                        dtNode.Entities.SetNamedItem( ent );
                    }
                }

                if (schInfo.ParameterEntities != null) {
                    foreach( SchemaEntity scEnt in schInfo.ParameterEntities.Values ) {
                        XmlEntity ent = new XmlEntity( scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, doc );
                        ent.SetBaseURI( scEnt.DeclaredURI );
                        dtNode.Entities.SetNamedItem( ent );
                    }
                }
                doc.Entities = dtNode.Entities;

                //extract the elements which has attribute defined as ID from the element declarations
                IDictionaryEnumerator elementDecls = schInfo.ElementDecls.GetEnumerator();
                if (elementDecls != null) {
                    elementDecls.Reset();
                    while (elementDecls.MoveNext()) {
                        SchemaElementDecl elementDecl = (SchemaElementDecl)elementDecls.Value;
                        if (elementDecl.AttDefs != null) {
                            IDictionaryEnumerator attDefs =  elementDecl.AttDefs.GetEnumerator();
                            while (attDefs.MoveNext()) {
                                SchemaAttDef attdef = (SchemaAttDef)attDefs.Value;
                                if (attdef.Datatype.TokenizedType == XmlTokenizedType.ID) {
                                    doc.AddIdInfo(
                                        doc.GetXmlName(elementDecl.Name.Name, elementDecl.Name.Namespace),
                                        doc.GetXmlName(attdef.Name.Name, attdef.Name.Namespace));
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
開發者ID:ArildF,項目名稱:masters,代碼行數:53,代碼來源:xmlloader.cs


注:本文中的System.Xml.XmlValidatingReader.GetSchemaInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。