久久久久久久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 針對架構(gòu)驗證 XML

        Using .NET to validate XML against a schema(使用 .NET 針對架構(gòu)驗證 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 針對架構(gòu)驗證 XML的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

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

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

                  值得一提的是,該架構(gòu)是 Word 2003 WordML 架構(gòu),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 代碼進(jìn)行驗證:

                  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 方法顯式添加:當(dāng)機器未連接到 Internet 時,驗證現(xiàn)在可以正常工作.

                  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.

                  但是,當(dāng)機器連接到 Internet 時,我現(xiàn)在收到一條錯誤消息,指出 全局屬性 '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..

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

                  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).

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

                  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?

                  推薦答案

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

                  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.

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

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

                  相關(guān)文檔推薦

                  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(從函數(shù)調(diào)用按鈕 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. 主站蜘蛛池模板: 日本一道本 | 国产成人免费视频网站视频社区 | 亚洲日本一区二区 | 二区三区视频 | 久久99视频 | 天天干天天干 | av特级毛片 | 天天射网站 | 天天射中文| 亚洲精品久久久久久国产精华液 | 在线视频 欧美日韩 | 亚洲国产欧美国产综合一区 | 亚洲国产欧美国产综合一区 | 久久久久国产精品一区二区 | 久久精品视频播放 | 欧美黄色一区 | 国产无套一区二区三区久久 | 精品国产欧美一区二区 | 国产免国产免费 | 亚洲高清在线观看 | 999久久久久久久久6666 | 超碰婷婷 | 日韩精品一区二区三区四区视频 | 欧美h版 | 国产九九精品视频 | 黄在线免费观看 | 久久成人国产 | 国产成人网| 国产精品亚洲一区二区三区在线 | 亚洲综合色网 | 日本在线看片 | 欧美激情一区二区 | 国产一区二区欧美 | 国产视频一区二区 | 日本午夜视频 | 亚洲毛片 | 视频三区 | 免费人成在线观看网站 | 凹凸日日摸日日碰夜夜 | 91精品国产91综合久久蜜臀 | 欧美黄色片在线观看 |