久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    1. <legend id='fERfZ'><style id='fERfZ'><dir id='fERfZ'><q id='fERfZ'></q></dir></style></legend>
        <bdo id='fERfZ'></bdo><ul id='fERfZ'></ul>

    2. <tfoot id='fERfZ'></tfoot>

      <small id='fERfZ'></small><noframes id='fERfZ'>

      <i id='fERfZ'><tr id='fERfZ'><dt id='fERfZ'><q id='fERfZ'><span id='fERfZ'><b id='fERfZ'><form id='fERfZ'><ins id='fERfZ'></ins><ul id='fERfZ'></ul><sub id='fERfZ'></sub></form><legend id='fERfZ'></legend><bdo id='fERfZ'><pre id='fERfZ'><center id='fERfZ'></center></pre></bdo></b><th id='fERfZ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='fERfZ'><tfoot id='fERfZ'></tfoot><dl id='fERfZ'><fieldset id='fERfZ'></fieldset></dl></div>
    3. c# XML Schema 驗證

      c# XML Schema validation(c# XML Schema 驗證)
        <tbody id='zTq0f'></tbody>
    4. <i id='zTq0f'><tr id='zTq0f'><dt id='zTq0f'><q id='zTq0f'><span id='zTq0f'><b id='zTq0f'><form id='zTq0f'><ins id='zTq0f'></ins><ul id='zTq0f'></ul><sub id='zTq0f'></sub></form><legend id='zTq0f'></legend><bdo id='zTq0f'><pre id='zTq0f'><center id='zTq0f'></center></pre></bdo></b><th id='zTq0f'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='zTq0f'><tfoot id='zTq0f'></tfoot><dl id='zTq0f'><fieldset id='zTq0f'></fieldset></dl></div>

      1. <small id='zTq0f'></small><noframes id='zTq0f'>

          <legend id='zTq0f'><style id='zTq0f'><dir id='zTq0f'><q id='zTq0f'></q></dir></style></legend>

            <tfoot id='zTq0f'></tfoot>
              • <bdo id='zTq0f'></bdo><ul id='zTq0f'></ul>
                本文介紹了c# XML Schema 驗證的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我有一個很好的 XML 文件,如下所示:

                I have a nice XML file like this:

                    <?xml version="1.0" encoding="utf-8" ?>
                    <Assets Path="C:Users
                3plicaGoogle Drive">
                        <Assetd>
                            <FileName>Boomerang - Error codes.xlsx</FileName>
                            <DisplayName>Boomerang - Error codes</DisplayName>
                            <Description>This is the Boomerang error codes file</Description>
                            <Tags>
                                <Tag>Excel</Tag>
                                <Tag>Boomerang</Tag>
                            </Tags>
                            <Categories>
                                <Category>1</Category>
                                <Category>4</Category>
                            </Categories>
                        </Assetd>
                        <Asset>
                            <FileName>Issue Tracker v5.xlsx</FileName>
                            <Description>This is the issue tracker for Skipstone</Description>
                            <Tags>
                                <Tag>Excel</Tag>
                                <Tag>Skipstone</Tag>
                            </Tags>
                            <Categories>
                                <Category>1</Category>
                                <Category>4</Category>
                            </Categories>
                        </Asset>
                    </Assets>
                

                然后我有我這樣創建的架構:

                and then I have my schema which I created like this:

                    <?xml version="1.0" encoding="utf-8"?>
                    <xs:schema id="data"
                        targetNamespace="http://tempuri.org/data.xsd"
                        elementFormDefault="qualified"
                        xmlns="http://tempuri.org/data.xsd"
                        xmlns:mstns="http://tempuri.org/data.xsd"
                        xmlns:xs="http://www.w3.org/2001/XMLSchema"
                    >
                      <xs:element name="Assets">
                        <xs:complexType>
                          <xs:sequence>
                            <xs:element name="Asset" type="Asset" minOccurs="1" />
                          </xs:sequence>
                        </xs:complexType>
                      </xs:element>
                
                      <xs:complexType name="Asset">
                        <xs:sequence>
                          <xs:element name="FileName" type="xs:string" minOccurs="1" maxOccurs="1" />
                          <xs:element name="DisplayName" type="xs:string" minOccurs="0" maxOccurs="1" />
                          <xs:element name="Description" type="xs:string" minOccurs="0" maxOccurs="1" />
                          <xs:element name="Tags" type="Tags" minOccurs="0" maxOccurs="1" />
                          <xs:element name="Categories" type="Categories" minOccurs="1" maxOccurs="1" />
                        </xs:sequence>
                      </xs:complexType>
                
                      <xs:complexType name="Tags">
                        <xs:sequence>
                          <xs:element name="Tag" type="xs:string" minOccurs="1" maxOccurs="unbounded" />
                        </xs:sequence>
                      </xs:complexType>
                
                      <xs:complexType name="Categories">
                        <xs:sequence>
                          <xs:element name="Category" type="xs:int" minOccurs="1" maxOccurs="unbounded" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:schema>
                

                據我所見,xml 文件無效,因為第一個元素是 Assetd 而不是 Asset,但如果我運行我的 c# 代碼:

                As far as I can see looking at that, the xml file is invalid because the first element is Assetd and not Asset, but if I run my c# code:

                XmlSchemaSet schemas = new XmlSchemaSet();
                schemas.Add("http://tempuri.org/data.xsd", "data.xsd");
                
                XDocument doc = XDocument.Load(openFileDialog1.FileName);
                string msg = "";
                doc.Validate(schemas, (o, err) =>
                {
                    msg = err.Message;
                });
                Console.WriteLine(msg == "" ? "Document is valid" : "Document invalid: " + msg);
                

                它告訴我 xml 是有效的...如果我使用此代碼:

                it tells me the xml is valid... If I use this code:

                // Set the validation settings.
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.ValidationType = ValidationType.Schema;
                settings.Schemas.Add("http://tempuri.org/data.xsd", "data.xsd");
                settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
                settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;
                settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
                settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
                
                // Create the XmlReader object.
                XmlReader reader = XmlReader.Create(openFileDialog1.FileName, settings);
                
                // Parse the file. 
                while (reader.Read()) ;
                

                我在控制臺中得到這個輸出:

                I get this output in the console:

                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Assets'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the attribute 'Path'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Assetd'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'FileName'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'DisplayName'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Description'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Tags'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Tag'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Tag'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Categories'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Category'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Category'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Asset'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'FileName'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Description'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Tags'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Tag'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Tag'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Categories'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Category'.
                Warning: Matching schema not found.  No validation occurred. Could not find schema information for the element 'Category'.
                

                誰能告訴我我做錯了什么嗎?它正在殺死我:(

                Can anyone tell me what I am doing wrong please? It is killing me :(

                干杯,/r3plica

                cheers, /r3plica

                推薦答案

                你需要在你的xml中設置默認命名空間,像這樣:

                You need to set default namespace in your xml, like this:

                <?xml version="1.0" encoding="utf-8"  ?>
                    <Assets xmlns="http://tempuri.org/data.xsd">
                        <Asset>
                            <FileName>Boomerang - Error codes.xlsx</FileName>
                            <DisplayName>Boomerang - Error codes</DisplayName>
                            <Description>This is the Boomerang error codes file</Description>
                            <Tags>
                                <Tag>Excel</Tag>
                                <Tag>Boomerang</Tag>
                            </Tags>
                            <Categories>
                                <Category>1</Category>
                                <Category>4</Category>
                            </Categories>
                        </Asset>
                        <Asset>
                            <FileName>Issue Tracker v5.xlsx</FileName>
                            <Description>This is the issue tracker for Skipstone</Description>
                            <Tags>
                                <Tag>Excel</Tag>
                                <Tag>Skipstone</Tag>
                            </Tags>
                            <Categories>
                                <Category>1</Category>
                                <Category>4</Category>
                            </Categories>
                        </Asset>
                    </Assets>
                

                此外,還有許多其他問題:

                Also, there is a number of other problems:

                模式中未定義路徑屬性,未定義Assetd"元素.maxOccurs="unbounded" 需要在 xs:element name="Asset" 的架構中設置

                Path attribute is not defined in schema, 'Assetd' element is not defined. maxOccurs="unbounded" need to be set in schema for xs:element name="Asset"

                如果無法修改xml,則需要從xsd中移除目標架構:

                In case if you cannot modify xml, you need to remove target schema from xsd:

                <xs:schema id="data"
                    xmlns:mstns="http://tempuri.org/data.xsd"
                    xmlns:xs="http://www.w3.org/2001/XMLSchema"
                >
                

                并像這樣注冊架構:

                settings.Schemas.Add(null, "data.xsd");
                

                這篇關于c# XML Schema 驗證的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                onClick event for Image in Unity(Unity中圖像的onClick事件)
                Running Total C#(運行總 C#)
                Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                Calling A Button OnClick from a function(從函數調用按鈕 OnClick)
                  <tbody id='wsV2M'></tbody>

                <small id='wsV2M'></small><noframes id='wsV2M'>

                  <tfoot id='wsV2M'></tfoot>
                • <legend id='wsV2M'><style id='wsV2M'><dir id='wsV2M'><q id='wsV2M'></q></dir></style></legend>
                      • <bdo id='wsV2M'></bdo><ul id='wsV2M'></ul>

                      • <i id='wsV2M'><tr id='wsV2M'><dt id='wsV2M'><q id='wsV2M'><span id='wsV2M'><b id='wsV2M'><form id='wsV2M'><ins id='wsV2M'></ins><ul id='wsV2M'></ul><sub id='wsV2M'></sub></form><legend id='wsV2M'></legend><bdo id='wsV2M'><pre id='wsV2M'><center id='wsV2M'></center></pre></bdo></b><th id='wsV2M'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='wsV2M'><tfoot id='wsV2M'></tfoot><dl id='wsV2M'><fieldset id='wsV2M'></fieldset></dl></div>

                          主站蜘蛛池模板: 欧美精品在线一区二区三区 | 国际精品鲁一鲁一区二区小说 | 免费观看成人鲁鲁鲁鲁鲁视频 | 国产中文字幕在线观看 | 欧美久久一区二区三区 | 日本粉嫩一区二区三区视频 | 一区二区三区欧美在线观看 | 久久精品国产久精国产 | 亚洲首页 | 一区二区视频免费观看 | 在线一区观看 | 久久成人精品 | 久久精品国产免费看久久精品 | 二区在线视频 | 91av亚洲| 久久久人 | 国产色视频网站 | 国产美女福利在线观看 | 婷婷桃色网 | 国产免费一区二区三区 | 精品亚洲一区二区三区 | 最新av在线播放 | 国产二区av | 久久这里只有精品首页 | 一级黄色淫片 | 久久久性色精品国产免费观看 | 精品欧美色视频网站在线观看 | 粉嫩国产精品一区二区在线观看 | av网站观看 | 夜久久| 日韩精品一区二区三区中文字幕 | 成人a网 | 一区二区视频在线 | 射久久| 日韩精品一区二区久久 | 成人午夜精品 | 亚洲一区二区av | 国产精品综合 | 午夜精品久久久 | 成人国产在线视频 | 人人干免费 |