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

    <bdo id='89GwW'></bdo><ul id='89GwW'></ul>

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

        <tfoot id='89GwW'></tfoot>
      2. 使用 .NET 針對架構驗證 XML

        Using .NET to validate XML against a schema(使用 .NET 針對架構驗證 XML)
      3. <i id='KtK9U'><tr id='KtK9U'><dt id='KtK9U'><q id='KtK9U'><span id='KtK9U'><b id='KtK9U'><form id='KtK9U'><ins id='KtK9U'></ins><ul id='KtK9U'></ul><sub id='KtK9U'></sub></form><legend id='KtK9U'></legend><bdo id='KtK9U'><pre id='KtK9U'><center id='KtK9U'></center></pre></bdo></b><th id='KtK9U'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='KtK9U'><tfoot id='KtK9U'></tfoot><dl id='KtK9U'><fieldset id='KtK9U'></fieldset></dl></div>
              <tbody id='KtK9U'></tbody>
          1. <small id='KtK9U'></small><noframes id='KtK9U'>

            • <bdo id='KtK9U'></bdo><ul id='KtK9U'></ul>
              • <tfoot id='KtK9U'></tfoot>

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

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

                  問題描述

                  限時送ChatGPT賬號..

                  我想測試(真或假)任意 XML 文件是否與給定架構匹配.

                  I want to test (true or false) whether an arbitrary XML file matches a given schema.

                  值得一提的是,該架構是 Word 2003 WordML 架構,Microsoft 使用大約 7 個 *.xsd 文件的列表來定義它.

                  For what it's worth, the schema is the Word 2003 WordML schema, which Microsoft defines using a list of about 7 *.xsd files.

                  其中一個文件還包括 W3C xml.xsd 文件,包括以下語句:

                  One of these files also includes the W3C xml.xsd file, by including the following statement:

                  <xsd:import id="xml" namespace="http://www.w3.org/XML/1998/namespace"
                      schemaLocation="http://www.w3.org/2001/xml.xsd"></xsd:import>
                  

                  我正在使用如下所示的 .NET 代碼進行驗證:

                  I am using .NET code like the following to do the validation:

                     public static void validate(string filename)
                      {
                         XmlReaderSettings settings = new XmlReaderSettings();
                         settings.Schemas.Add(
                             "http://schemas.microsoft.com/office/word/2003/wordml",
                             //to get this file I downloaded "Office 2003: XML Reference Schemas", i.e. "Office2003XMLSchema.exe" 
                             @"C:Program FilesMicrosoft Office 2003 Developer ResourcesMicrosoft Office 2003 XML Reference SchemasWordprocessingML Schemaswordnet.xsd"
                             );
                          settings.ValidationType = ValidationType.Schema;
                          settings.ValidationEventHandler += new ValidationEventHandler(validationEventHandler);
                          XmlReader xmlReader = XmlReader.Create(filename, settings);
                          while (xmlReader.Read()) { }
                     }
                  

                  我的問題是,如果我在未連接到 Internet 的機器上運行此代碼,則會收到 XmlSchemaValidationException 錯誤,大意是找不到 xml.xsd.

                  My problem is that if I run this code on a machine which is not connected to the internet, then I get a XmlSchemaValidationException error to the effect that it can't find xml.xsd.

                  為了解決這個問題,我下載了 xml.xsd 的副本,并使用 settings.Schemas.Add 方法顯式添加:當機器未連接到 Internet 時,驗證現在可以正常工作.

                  To fix this, I downloaded a copy of xml.xsd, and add it explicitly using the settings.Schemas.Add method: the validation now works correctly when the machine is not connected to the internet.

                  但是,當機器連接到 Internet 時,我現在收到一條錯誤消息,指出 全局屬性 'http://www.w3.org/XML/1998/namespace:lang' 已被聲明..

                  However when the machine is connected to the internet, I now get an error saying that The global attribute 'http://www.w3.org/XML/1998/namespace:lang' has already been declared..

                  所以顯然我需要明確添加它,或者我不需要,這取決于機器是否能夠從互聯網上靜默下載它(或者甚至可能以前能夠下載它,并將它緩存在某個地方).

                  So apparently I either need to add it explicitly, or I don't, depending on whether the machine is able to silently download it from the internet (or even perhaps has previously been able to download it, and has it cached somewhere).

                  所以,它是如果我這樣做該死,如果我不這樣做該死".我是否需要以一種方式嘗試,捕獲異常,然后以另一種方式嘗試?還是有更優雅的解決方案?

                  So, it's "damned if I do and damned if I don't". Do I need to try it one way, catch the exception and then try it the other way? Or is there a more elegant solution?

                  推薦答案

                  我們看不到您的代碼,但是在許多實現中,這是通過將 .xsd 的請求重定向到本地來處理的使用目錄解析器進行復制.有一個屬性 XmlReaderSettings.XmlResolver可用于此.請參閱 XMLCatalog.net 了解您可以使用的 Apache 許可實現.

                  We can't see your code, but In many implementations this is handled by redirecting the request for the .xsd to the local copy using a catalog resolver. There is a property XmlReaderSettings.XmlResolver that can be used for this. See XMLCatalog.net for an Apache-licensed implementation you can use.

                  這樣做的副作用是您可以將所有模式緩存在本地.這一點尤其重要,因為 W3C 會阻止對其站點的過度讀取,并且您的代碼(或更糟糕的是,您客戶的代碼)會隨機開始失敗.

                  A side-effect of this is that you can keep all schemas cached locally. This is especially important since W3C will block excessive reads to their site and randomly your code (or worse, your customer's code) will begin to fail.

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

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

                  相關文檔推薦

                  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)
                  ASP.net C# Gridview ButtonField onclick event(ASP.net C# Gridview ButtonField onclick 事件)
                  Adding OnClick event to ASP.NET control(將 OnClick 事件添加到 ASP.NET 控件)
                  Multiple submit Button click problem?(多個提交按鈕點擊問題?)
                1. <small id='BNSca'></small><noframes id='BNSca'>

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

                          1. 主站蜘蛛池模板: se婷婷 | 最近日韩中文字幕 | 国产午夜一级 | 涩涩视频网站在线观看 | 亚洲精品乱码久久久久久黑人 | 日韩av在线一区 | 影音先锋欧美资源 | 国产精品久久久久久久久久久免费看 | 久久久精彩视频 | 久久国际精品 | 国产在线成人 | 在线色| 亚洲精品国产第一综合99久久 | 玖玖玖在线| 成人国产免费观看 | 欧美aaaaa| 国产精品一区在线观看 | 欧美一区二区三区视频 | 久久成人免费视频 | 国产成人福利视频在线观看 | 欧美自拍日韩 | 国产成人高清在线观看 | 日本免费一区二区三区四区 | 日韩一区二区三区在线 | av高清| 美女福利视频 | 久久av一区| 国产精品揄拍一区二区 | 婷婷精品 | 成人国产在线观看 | 国产精品无码专区在线观看 | 天堂资源最新在线 | 国产伦精品一区二区三区精品视频 | 日韩欧美在线播放 | 蜜桃视频在线观看免费视频网站www | 国产91视频一区二区 | 久久国产精品一区二区 | 欧美在线资源 | 久久一区二区三区四区五区 | 黄色片在线免费看 | 国产69久久精品成人看动漫 |