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

  • <legend id='8YsTP'><style id='8YsTP'><dir id='8YsTP'><q id='8YsTP'></q></dir></style></legend>

    <small id='8YsTP'></small><noframes id='8YsTP'>

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

      1. <tfoot id='8YsTP'></tfoot>
        • <bdo id='8YsTP'></bdo><ul id='8YsTP'></ul>

        如何從 XMLType 節(jié)點(diǎn)中提取元素路徑?

        How to extract element-path from XMLType Node?(如何從 XMLType 節(jié)點(diǎn)中提取元素路徑?)

              <bdo id='DjYZe'></bdo><ul id='DjYZe'></ul>
                <tbody id='DjYZe'></tbody>
              <legend id='DjYZe'><style id='DjYZe'><dir id='DjYZe'><q id='DjYZe'></q></dir></style></legend>
                <tfoot id='DjYZe'></tfoot>

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

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

                  本文介紹了如何從 XMLType 節(jié)點(diǎn)中提取元素路徑?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

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

                  我想要一個(gè)關(guān)于 XML 文檔的選擇語句,并且一列應(yīng)該返回每個(gè)節(jié)點(diǎn)的路徑.

                  I would like to have a select statement on an XML document and one column should return me the path of each node.

                  例如,給定數(shù)據(jù)

                  SELECT * 
                  FROM TABLE(XMLSequence(
                    XMLTYPE('<?xml version="1.0"?>
                      <users><user><name>user1</name></user>
                             <user><name>user2</name></user>
                             <group>
                                <user><name>user3</name></user>
                             </group>
                             <user><name>user4</name></user>
                      </users>').extract('/*//*[text()]'))) t;
                  

                  結(jié)果

                  column_value
                  --------
                  <user><name>user1</name></user>
                  <user><name>user2</name></user>
                  <user><name>user3</name></user>
                  <user><name>user4</name></user>
                  

                  我想要這樣的結(jié)果:

                  path                     value
                  ------------------------ --------------
                  /users/user/name         user1
                  /users/user/name         user2
                  /users/group/user/name   user3
                  /users/user/name         user4
                  

                  我不知道如何做到這一點(diǎn).我認(rèn)為有兩件事必須正確協(xié)同工作:

                  I can not see how to get to this. I figure there are two thing that have to work together properly:

                  • 我可以使用單個(gè)操作或方法從 XMLType 中提取 path,或者我必須使用 string-magic 來執(zhí)行此操作嗎??
                  • 什么是正確的 XPath 表達(dá)式,以便我獲得整個(gè)元素路徑(如果可能的話),例如.<users><group><user><name>user3</name></user></group></user><;用戶>user3?
                  • Can I extract the path from an XMLType with a single operation or method, or do I have to do this with string-magic?
                  • What is the correct XPath expression so that I do get the whole element path (if thats possible), eg. <users><group><user><name>user3</name></user></group></user> insead of <user><name>user3</name></user>?

                  也許我還沒有完全理解 XMLType.可能是我需要不同的方法,但我看不到.

                  Maybe I am not understanding XMLType fully, yet. It could be I need a different approach, but I can not see it.

                  旁注:

                  • 在最終版本中,XML 文檔將來自表的 CLOB,而不是靜態(tài)文檔.
                  • path 列當(dāng)然也可以使用點(diǎn)或其他任何東西,并且最初的斜杠不是問題,任何表示都可以.
                  • 此外,我不介意每個(gè)內(nèi)部節(jié)點(diǎn)是否也獲得一個(gè)結(jié)果行(可能將 null 作為 value),而不僅僅是帶有 text() 的那些 在其中(這是我真正感興趣的).
                  • 最后,我需要將 pathtail 元素 分開(在示例中總是 "name",但這會(huì)有所不同稍后),即 ('/users/groups/user', 'name', 'user3'),我可以單獨(dú)處理.
                  • In the final version the XML document will be coming from CLOBs of a table, not a static document.
                  • The path column can of course also use dots or whatever and the initial slash is not the issue, any representation would do.
                  • Also I would not mind if every inner node also gets a result row (possibly with null as value), not only the ones with text() in it (which is what I am really interested in).
                  • In the end I will need the tail element of path separate (always "name" in the example here, but this will vary later), i.e. ('/users/groups/user', 'name', 'user3'), I can deal with that separately.

                  推薦答案

                  您可以在 XMLTable 函數(shù)來自 Oracle XML DB XQuery 函數(shù)集:

                  You can achieve that with help of XMLTable function from Oracle XML DB XQuery function set:

                  select * from 
                    XMLTable(
                      '
                       declare function local:path-to-node( $nodes as node()* )  as xs:string* {
                         $nodes/string-join(ancestor-or-self::*/name(.), ''/'')
                       };
                       for $i in $rdoc//name 
                         return <ret><name_path>{local:path-to-node($i)}</name_path>{$i}</ret>
                      '
                      passing 
                      XMLParse(content '
                        <users><user><name>user1</name></user>
                             <user><name>user2</name></user>
                             <group>
                                <user><name>user3</name></user>
                             </group>
                             <user><name>user4</name></user>
                        </users>'
                      )
                      as "rdoc"
                      columns 
                        name_path  varchar2(4000) path '//ret/name_path',
                        name_value varchar2(4000) path '//ret/name'
                  
                    )
                  

                  對我來說,XQuery 看起來至少比 XSLT 對 XML 數(shù)據(jù)操作更直觀.

                  For me XQuery looks at least more intuitive for XML data manipulation than XSLT.

                  您可以在此處找到有用的 XQuery 函數(shù)集.

                  You can find useful set of XQuery functions here.

                  更新 1

                  我想您在最后階段需要具有完整數(shù)據(jù)的完全簡單的數(shù)據(jù)集.這個(gè)目標(biāo)可以通過復(fù)雜的方式達(dá)到,下面一步一步構(gòu)建,但是這個(gè)變體非常耗費(fèi)資源.我建議審查最終目標(biāo)(選擇一些特定的記錄,計(jì)算元素?cái)?shù)量等),然后簡化此解決方案或完全更改它.

                  I suppose that you need totally plain dataset with full data at last stage. This target can be reached by complicated way, constructed step-by-step below, but this variant is very resource-angry. I propose to review final target (selecting some specific records, count number of elements etc.) and after that simplify this solution or totally change it.

                  更新 2

                  除了最后一步之外,所有步驟都從此更新中刪除,因?yàn)锧A.B.Cade 在評(píng)論中提出了更優(yōu)雅的解決方案.此解決方案在下面的更新 3 部分中提供.

                  All steps deleted from this Update except last because @A.B.Cade proposed more elegant solution in comments. This solution provided in Update 3 section below.

                  Step 1 - 構(gòu)建帶有對應(yīng)查詢結(jié)果的 id 數(shù)據(jù)集

                  Step 1 - Constructing dataset of id's with corresponding query results

                  第 2 步 - 聚合到單個(gè) XML 行

                  Step 2 - Aggregating to single XML row

                  第 3 步 - 最后通過使用 XMLTable 查詢壓縮的 XML 獲得完整的普通數(shù)據(jù)集

                  Step 3 - Finally get full plain dataset by querying constracted XML with XMLTable

                  with xmlsource as (
                    -- only for purpose to write long string only once
                    select '
                        <users><user><name>user1</name></user>
                             <user><name>user2</name></user>
                             <group>
                                <user><name>user3</name></user>
                             </group>
                             <user><name>user4</name></user>
                        </users>' xml_string
                     from dual   
                  ),
                  xml_table as ( 
                    -- model of xmltable
                    select 10 id, xml_string xml_data from xmlsource union all 
                    select 20 id, xml_string xml_data from xmlsource union all 
                    select 30 id, xml_string xml_data from xmlsource 
                  ) 
                  select  *
                  from
                    XMLTable(
                      '
                          for $entry_user in $full_doc/full_list/list_entry/name_info
                            return <tuple>
                                     <id>{data($entry_user/../@id_value)}</id>
                                     <path>{$entry_user/name_path/text()}</path>
                                     <name>{$entry_user/name_value/text()}</name>
                                    </tuple> 
                      '
                      passing ( 
                        select  
                          XMLElement("full_list", 
                            XMLAgg(     
                              XMLElement("list_entry",
                                XMLAttributes(id as "id_value"),
                                XMLQuery(
                                  '
                                   declare function local:path-to-node( $nodes as node()* )  as xs:string* {
                                     $nodes/string-join(ancestor-or-self::*/name(.), ''/'')
                                   };(: function to construct path :) 
                                   for $i in $rdoc//name return <name_info><name_path>{local:path-to-node($i)}</name_path><name_value>{$i/text()}</name_value></name_info>
                                  '
                                  passing by value XMLParse(content xml_data) as "rdoc"
                                  returning content
                                )
                              )
                            )
                          )        
                          from xml_table
                      )   
                      as "full_doc"      
                      columns
                        id_val   varchar2(4000) path '//tuple/id',
                        path_val varchar2(4000) path '//tuple/path',
                        name_val varchar2(4000) path '//tuple/name'
                    )    
                  

                  更新 3

                  正如@A.B.Cade 在他的評(píng)論中提到的,有非常簡單的方法可以將 ID 與 XQuery 結(jié)果連接起來.

                  As mentioned by @A.B.Cade in his comment, there are really simple way to join ID's with XQuery results.

                  因?yàn)槲也幌矚g答案中的外部鏈接,下面的代碼代表他的 SQL 小提琴,有點(diǎn)適應(yīng)這個(gè)答案的數(shù)據(jù)源:

                  Because I don't like external links in answers, code below represents his SQL fiddle, a little bit adapted to the data source from this answer:

                  with xmlsource as (
                    -- only for purpose to write long string only once
                    select '
                        <users><user><name>user1</name></user>
                             <user><name>user2</name></user>
                             <group>
                                <user><name>user3</name></user>
                             </group>
                             <user><name>user4</name></user>
                        </users>' xml_string
                     from dual   
                  ),
                  xml_table as ( 
                    -- model of xmltable
                    select 10 id, xml_string xml_data from xmlsource union all 
                    select 20 id, xml_string xml_data from xmlsource union all
                    select 30 id, xml_string xml_data from xmlsource
                  )
                  select xd.id, x.*  from
                  xml_table xd,
                    XMLTable(
                      'declare function local:path-to-node( $nodes as node()* )  as xs:string* {$nodes/string-join(ancestor-or-self::*/name(.), ''/'')     };     for $i in $rdoc//name        return <ret><name_path>{local:path-to-node($i)}</name_path>{$i}</ret>    '
                      passing
                      XMLParse(content xd.xml_data
                      )
                      as "rdoc"
                      columns
                        name_path  varchar2(4000) path '//ret/name_path',
                        name_value varchar2(4000) path '//ret/name'
                  
                    ) x
                  

                  這篇關(guān)于如何從 XMLType 節(jié)點(diǎn)中提取元素路徑?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產(chǎn)品、類別和元數(shù)據(jù)的 SQL 查詢 woocommerce/wordpress)
                  Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數(shù)據(jù)庫列表和 SQL Server 實(shí)例使用的空間嗎?) - IT屋-程序員軟件開發(fā)
                  How to create a login to a SQL Server instance?(如何創(chuàng)建對 SQL Server 實(shí)例的登錄?)
                  How to know the version and edition of SQL Server through registry search(如何通過注冊表搜索知道SQL Server的版本和版本)
                  Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會(huì)出現(xiàn)“數(shù)據(jù)類型轉(zhuǎn)換錯(cuò)誤?使用 ExecuteNonQuery()?)
                  How to show an image from a DataGridView to a PictureBox?(如何將 DataGridView 中的圖像顯示到 PictureBox?)

                        <tbody id='XGTBy'></tbody>

                      1. <tfoot id='XGTBy'></tfoot>
                      2. <small id='XGTBy'></small><noframes id='XGTBy'>

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

                        • <legend id='XGTBy'><style id='XGTBy'><dir id='XGTBy'><q id='XGTBy'></q></dir></style></legend>
                          <i id='XGTBy'><tr id='XGTBy'><dt id='XGTBy'><q id='XGTBy'><span id='XGTBy'><b id='XGTBy'><form id='XGTBy'><ins id='XGTBy'></ins><ul id='XGTBy'></ul><sub id='XGTBy'></sub></form><legend id='XGTBy'></legend><bdo id='XGTBy'><pre id='XGTBy'><center id='XGTBy'></center></pre></bdo></b><th id='XGTBy'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XGTBy'><tfoot id='XGTBy'></tfoot><dl id='XGTBy'><fieldset id='XGTBy'></fieldset></dl></div>
                            主站蜘蛛池模板: 午夜影院黄 | av入口| 国产精品特级毛片一区二区三区 | 天天综合成人网 | 日韩视频专区 | 国产精品自产拍在线观看蜜 | 黑人巨大精品欧美黑白配亚洲 | 国产三级一区二区三区 | 亚洲三区在线 | 伊人狠狠干 | av网址在线 | 久久久久一区二区三区四区 | 久久亚洲综合 | 国产96色在线| 日韩欧美在线一区二区 | 欧美九九| 国产激情综合五月久久 | 午夜a v电影 | 成人久久| 欧美日本韩国一区二区 | 久久久久国产精品一区二区 | 免费看黄色片 | 欧美日韩黄色一级片 | 国产精品毛片无码 | 91精品国产91久久综合桃花 | 午夜精品久久久久久 | 日本三级在线 | 亚洲美女一区二区三区 | 欧美一区二区综合 | 中文日本在线 | 四季久久免费一区二区三区四区 | 奇米久久久| 午夜影院在线视频 | 日韩国产精品一区二区三区 | 精产国产伦理一二三区 | 亚洲成人精品在线 | 一区二区在线观看免费视频 | 精品国产一区二区三区久久 | 久久极品 | aa级毛片毛片免费观看久 | 久久极品 |