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

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

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

          <bdo id='gFeSQ'></bdo><ul id='gFeSQ'></ul>
        <legend id='gFeSQ'><style id='gFeSQ'><dir id='gFeSQ'><q id='gFeSQ'></q></dir></style></legend>
        <tfoot id='gFeSQ'></tfoot>
      1. 開始使用 .NET 進行 XSD 驗證

        Getting started with XSD validation with .NET(開始使用 .NET 進行 XSD 驗證)
        <tfoot id='yzErZ'></tfoot>

          1. <i id='yzErZ'><tr id='yzErZ'><dt id='yzErZ'><q id='yzErZ'><span id='yzErZ'><b id='yzErZ'><form id='yzErZ'><ins id='yzErZ'></ins><ul id='yzErZ'></ul><sub id='yzErZ'></sub></form><legend id='yzErZ'></legend><bdo id='yzErZ'><pre id='yzErZ'><center id='yzErZ'></center></pre></bdo></b><th id='yzErZ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yzErZ'><tfoot id='yzErZ'></tfoot><dl id='yzErZ'><fieldset id='yzErZ'></fieldset></dl></div>
              <tbody id='yzErZ'></tbody>
          2. <legend id='yzErZ'><style id='yzErZ'><dir id='yzErZ'><q id='yzErZ'></q></dir></style></legend>

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

                  <bdo id='yzErZ'></bdo><ul id='yzErZ'></ul>

                  本文介紹了開始使用 .NET 進行 XSD 驗證的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  這是我第一次嘗試使用 XSD 驗證 XML.

                  Here is my first attempt at validating XML with XSD.

                  要驗證的 XML 文件:

                  The XML file to be validated:

                  <?xml version="1.0" encoding="utf-8" ?>
                  <config xmlns="Schemas" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="config.xsd">
                    <levelVariant>
                      <filePath>SampleVariant</filePath>
                    </levelVariant>
                    <levelVariant>
                      <filePath>LegendaryMode</filePath>
                    </levelVariant>
                    <levelVariant>
                      <filePath>AmazingMode</filePath>
                    </levelVariant>
                  </config>
                  

                  XSD,位于Schemas/config.xsd"中,相對于要驗證的 XML 文件:

                  The XSD, located in "Schemas/config.xsd" relative to the XML file to be validated:

                  <?xml version="1.0" encoding="utf-8" ?>
                  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
                    <xs:element name="config">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="levelVariant">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="filePath" type="xs:anyURI">
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:schema>
                  

                  現在,我只想準確地驗證 XML 文件的當前顯示.一旦我更好地理解這一點,我將展開更多.對于像當前存在的 XML 文件這樣簡單的東西,我真的需要這么多行嗎?

                  Right now, I just want to validate the XML file precisely as it appears currently. Once I understand this better, I'll expand more. Do I really need so many lines for something as simple as the XML file as it currently exists?

                  C#中的驗證代碼:

                          public void SetURI(string uri)
                          {
                              XElement toValidate = XElement.Load(Path.Combine(PATH_TO_DATA_DIR, uri) + ".xml");
                  
                  // begin confusion
                  
                         // exception here
                         string schemaURI = toValidate.Attributes("xmlns").First().ToString() 
                                                + toValidate.Attributes("xsi:noNamespaceSchemaLocation").First().ToString();
                          XmlSchemaSet schemas = new XmlSchemaSet();
                          schemas.Add(null, schemaURI);
                  
                          XDocument toValidateDoc = new XDocument(toValidate);
                          toValidateDoc.Validate(schemas, null);
                  // end confusion
                  
                              root = toValidate;
                          }
                  

                  運行上面的代碼會出現這個異常:

                  Running the above code gives this exception:

                  The ':' character, hexadecimal value 0x3A, cannot be included in a name.
                  

                  任何照明都將不勝感激.

                  Any illumination would be appreciated.

                  推薦答案

                  而不是使用 XDocument.Validate 擴展方法,我會使用 XmlReader 可以配置為通過 XmlReaderSettings.您可以執行以下代碼之類的操作.

                  Rather than using the XDocument.Validate extension method, I would use an XmlReader which can be configured to process an inline schema via XmlReaderSettings. You could do some thing like the following code.

                  public void VerifyXmlFile(string path)
                  {
                      // configure the xmlreader validation to use inline schema.
                      XmlReaderSettings config = new XmlReaderSettings();
                      config.ValidationType = ValidationType.Schema;
                      config.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
                      config.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
                      config.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;
                      config.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
                  
                      // Get the XmlReader object with the configured settings.
                      XmlReader reader = XmlReader.Create(path, config);
                  
                      // Parsing the file will cause the validation to occur.
                      while (reader.Read()) ;
                  
                  }
                  
                  private void ValidationCallBack(object sender, ValidationEventArgs vea)
                  {
                      if (vea.Severity == XmlSeverityType.Warning)
                          Console.WriteLine(
                              "	Warning: Matching schema not found.  No validation occurred. {0}",
                              vea.Message);
                      else
                          Console.WriteLine("	Validation error: {0}", vea.Message);
                  
                  }
                  

                  上面的代碼假定以下 using 語句.

                  The code above assumes the following using statements.

                  using System.Xml;
                  using System.Xml.Schema;
                  

                  為了簡單起見,我沒有返回 boolean 或驗證錯誤集合,您可以輕松地修改它.

                  Just to keep this simple I did not return a boolean or a collection of validation errors, you could easily modify this to do so.

                  注意:我修改了您的 config.xml 和 config.xsd 以讓它們進行驗證.這些是我所做的更改.

                  Note: I modified your config.xml and config.xsd to get them to validate. These are the changes I made.

                  config.xsd:

                  config.xsd:

                  <xs:element maxOccurs="unbounded" name="levelVariant">
                  

                  config.xml:

                  config.xml:

                  <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="config.xsd">
                  

                  這篇關于開始使用 .NET 進行 XSD 驗證的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
                    <bdo id='ST80H'></bdo><ul id='ST80H'></ul>
                      • <legend id='ST80H'><style id='ST80H'><dir id='ST80H'><q id='ST80H'></q></dir></style></legend>
                        <tfoot id='ST80H'></tfoot>
                          <tbody id='ST80H'></tbody>

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

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

                          • 主站蜘蛛池模板: 色av一区二区 | 久久综合一区二区三区 | 91精品国产欧美一区二区成人 | 久久久久久国产精品三区 | 日韩av一区二区在线观看 | 美女高潮网站 | 亚洲国产成人在线视频 | 国产精品久久久久久婷婷天堂 | 欧美精品区 | 在线观看你懂的网站 | 在线看91 | 久久久久久久一区 | 精品99久久久久久 | 午夜成人免费视频 | 午夜精品福利视频 | 伊人影院在线观看 | 国产女人第一次做爰毛片 | 91资源在线 | 一级片免费视频 | 午夜影院网站 | 大香在线伊779 | 视频国产一区 | 91久久精 | 国产高清免费视频 | 99亚洲视频 | 久久新视频 | 国产一级片在线观看视频 | 51ⅴ精品国产91久久久久久 | 日韩在线欧美 | 久久网一区二区 | 一区二区在线免费播放 | 久久久青草婷婷精品综合日韩 | 亚洲人在线观看视频 | 亚洲精品一区二区三区蜜桃久 | 色视频网站 | 国产欧美一区二区三区日本久久久 | 欧美日韩国产高清 | 天堂av影院| 玖玖视频 | 成人伊人 | 中文字幕在线视频一区二区三区 |