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

將 xml-namespaces 限制為僅主根

Limit xml-namespaces to only the main root(將 xml-namespaces 限制為僅主根)
本文介紹了將 xml-namespaces 限制為僅主根的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有這個(gè)查詢

 WITH XMLNAMESPACES(DEFAULT 'https://tribunet.hacienda.go.cr /docs/esquemas/2017/v4.2/facturaElectronica'
                      ,'http://www.w3.org/2001/XMLSchema' AS xsd
                      ,'http://www.w3.org/2001/XMLSchema-instance' AS xsi)
SELECT 1 AS [id]
        ,0 AS [pass]
        (
         /*Others*/
        SELECT 
        OT.OTH_MESSAGE as Others
        FROM [crdx_COREDev1].[dbo].[OTH_OTHERS] as OT
        where 
        OT.OTH_ID=E.OTH_ID
        fOR XML PATH ('Others'), type

       )
      ,0 AS [CONSECUTIVE]

      FOR XML PATH('FE');

這會(huì)生成這個(gè) XML

<FE xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns="https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2    /facturaElectronica"> <- CHANGE 2
 <id>1</id>
 <pass>0</pass>
 <CONSECUTIVE>0</CONSECUTIVE>
 <Others xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns="https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2 /facturaElectronica">
 <MESSAGE>MESSAGE</MESSAGE>       
</Others> 
 </FE>

現(xiàn)在我的問題:我只希望 顯示命名空間,但是 - 正如您在 xml 中看到的 - 聲明也出現(xiàn)在 .如何將其限制為 ?

Now my question: I would like only <FE> to show the namespaces, but - as you see in the xml - that declarations appear also in <Others>. How can I limit this to <FE>?

推薦答案

這是一個(gè)令人討厭且眾所周知的問題,每當(dāng)您在 FOR XML 查詢中使用與嵌套子查詢相關(guān)的命名空間時(shí),就會(huì)發(fā)生此問題...

This is an annoying and well known issue and occurs whenever you use namespaces in connection with nested sub-queries in FOR XML queries...

連接問題已存在 10 多年 - 直到最近消失.

There has been a connect issue for more than 10 years - until it disappaered recently.

值得一提的是,這些重復(fù)的命名空間聲明并沒有錯(cuò),只是讓您的 XML 變得臃腫.它可能會(huì)與(以)嚴(yán)格的模式驗(yàn)證相沖突.

It is important to mention, that these repeated namespace declarations are not wrong, just bloating your XML. And it can collide with (to) strict schema validations.

沒有好的解決方案,只有解決方法:

No good solution, just workarounds:

  • 創(chuàng)建沒有命名空間的內(nèi)部 XML 并在字符串基礎(chǔ)上添加包裝節(jié)點(diǎn),或
  • 將命名空間創(chuàng)建為普通屬性(但未命名為 xmlns)并使用 REPLACE 更改名稱.
  • Create the inner XML without the namespace and add the wrapping node on string base, or
  • Create the namespaces as normal attributes (but not named xmlns) and use REPLACE to change the names.

兩種解決方法都需要轉(zhuǎn)換為 NVARCHAR(MAX) 并返回到 XML.

Both workarounds need a conversion to NVARCHAR(MAX) and back to XML.

我真的不知道,為什么要以這種方式實(shí)現(xiàn)...

I really have no idea, why this was implemented this way...

找一些相關(guān)的例子

  • 此處
  • 和此處
  • 和此處
  • 和此處

注意:

xmlns="https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2    /facturaElectronica">

您正在使用帶空格的命名空間 URL.這是不允許的...

You are using namespace URLs with blanks. This is not allowed...

這篇關(guān)于將 xml-namespaces 限制為僅主根的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個(gè)子標(biāo)記轉(zhuǎn)換為具有多個(gè)分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個(gè)表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計(jì)算值創(chuàng)建計(jì)算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對(duì)?) - IT屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(hào)(問題和答案的組合))
主站蜘蛛池模板: 日韩毛片在线观看 | 中文字幕日韩高清 | 黄色免费大片 | 欧美网站在线观看 | 国产成人毛片 | 一级黄色片网站 | 美女黄色在线观看 | 亚洲综合二区 | 国产在线欧美 | 午夜999| 天堂成人网 | 日韩二区三区 | 国产在线观看一区 | 亚洲视频不卡 | 天天插天天爽 | 特黄aaaaaaaaa真人毛片 | 日产毛片| 亚洲免费在线 | 欧美又大又硬又粗bbbbb | 波多野结衣视频在线 | 完全免费av| 日韩一级片视频 | 亚洲一级免费视频 | 欧美顶级黄色大片免费 | 999久久久久久久久6666 | 黄色网页在线 | 午夜免费网站 | 特级毛片爽www免费版 | 成人欧美一区二区三区白人 | 一级片观看| www久久久 | 成人一区二区三区 | 四川一级毛毛片 | 在线观看黄网站 | 91精品免费视频 | 日本国产欧美 | 成人国产在线观看 | www久久久久 | 黄色在线观看网址 | 最新日韩av | 久久狠狠干 |