久久久久久久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 進(jìn)行 XSD 驗(yàn)證

        Getting started with XSD validation with .NET(開始使用 .NET 進(jìn)行 XSD 驗(yàn)證)
        <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 進(jìn)行 XSD 驗(yàn)證的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  這是我第一次嘗試使用 XSD 驗(yàn)證 XML.

                  Here is my first attempt at validating XML with XSD.

                  要驗(yàn)證的 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"中,相對(duì)于要驗(yàn)證的 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>
                  

                  現(xiàn)在,我只想準(zhǔn)確地驗(yàn)證 XML 文件的當(dāng)前顯示.一旦我更好地理解這一點(diǎn),我將展開更多.對(duì)于像當(dāng)前存在的 XML 文件這樣簡(jiǎn)單的東西,我真的需要這么多行嗎?

                  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#中的驗(yàn)證代碼:

                          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;
                          }
                  

                  運(yùn)行上面的代碼會(huì)出現(xiàn)這個(gè)異常:

                  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 擴(kuò)展方法,我會(huì)使用 XmlReader 可以配置為通過 XmlReaderSettings.您可以執(zhí)行以下代碼之類的操作.

                  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 語(yǔ)句.

                  The code above assumes the following using statements.

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

                  為了簡(jiǎn)單起見,我沒有返回 boolean 或驗(yàn)證錯(cuò)誤集合,您可以輕松地修改它.

                  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 以讓它們進(jìn)行驗(yàn)證.這些是我所做的更改.

                  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">
                  

                  這篇關(guān)于開始使用 .NET 進(jìn)行 XSD 驗(yàn)證的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  What are good algorithms for vehicle license plate detection?(車牌檢測(cè)有哪些好的算法?)
                  onClick event for Image in Unity(Unity中圖像的onClick事件)
                  Running Total C#(運(yùn)行總 C#)
                  Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時(shí)刪除目錄)
                  asp.net listview highlight row on click(asp.net listview 在單擊時(shí)突出顯示行)
                  Calling A Button OnClick from a function(從函數(shù)調(diào)用按鈕 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网址 | 亚洲精品9999 | 亚洲欧洲在线视频 | 日韩精品一二三 | 国产精品亚洲第一 | 成人午夜免费网站 | 国产高清自拍视频在线观看 | 久久久久亚洲视频 | 久久青草av | 日本不卡高清视频 | 久久宗合色 | 久久精品一区 | 日韩欧美一区二区三区在线播放 | 性高湖久久久久久久久3小时 | 日韩综合在线 | 久久久国产一区二区三区 | 成人网av | 精品欧美一区二区精品久久久 | 免费一级黄色电影 | 国产精品自产拍在线观看蜜 | 亚洲在线免费观看 | 91精品国产777在线观看 | 国产精品久久久久久吹潮日韩动画 | 亚洲美女一区二区三区 | 国产精品欧美一区二区三区 | 欧美视频一区二区三区 | 亚洲精品一区二区三区蜜桃久 | 欧美一级片中文字幕 | 国产精品国产精品国产专区不卡 | 国产一区中文字幕 | 欧美日韩高清 | 操久久| 好好的日在线视频 | 黄页网址在线观看 | 91在线区 | 午夜免费视频 | 99综合在线| 亚洲一区二区三区四区五区午夜 | 亚洲综合色自拍一区 | 看片天堂|