sql >> Database teknologi >  >> RDS >> Oracle

Oracle XMLQuery ødelægger navneområdet

Dette ser ud til at være forventet adfærd ifølge My Oracle Support doc ID 2060374.1. Men ud fra en smule eksperimentering ser det ud til, at jokertegning af navneområdet i din XPath stopper det med at ske; så:

  <patent>{$m/*:patent/@*}
  {
    for $i in $m/*:patent/*
        return    $i
  }
  </patent>' 

Med dine originale data (i 11.2.0.4) og serialiseret for at formatere dem mere læsbart:

 WITH tmpTable AS (
SELECT * FROM XML_DOCUMENT_TMP cm )
SELECT tt.xml_data ,
XMLSerialize(DOCUMENT
XMLQuery('declare default element namespace  "http://schemas.thomson.com/ts/20041221/tsip";
      declare namespace  tsip="http://schemas.thomson.com/ts/20041221/tsip";
      declare namespace  tsxm="http://schemas.thomson.com/ts/20041221/tsxm";

      let $patsLus := $m/patent/*

      return          
      <patent>{$m/*:patent/@*}
      {
        for $i in $m/*:patent/*
            return    $i
      }
      </patent>' 
            PASSING tt.xml_data as "m"   RETURNING CONTENT)
 AS VARCHAR2(4000) INDENT SIZE = 2) ewXml 
 FROM tmpTable tt
 WHERE tt.document_id in (1);

XML_DATA
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
NEWXML
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<patent xmlns="http://schemas.thomson.com/ts/20041221/tsip" xmlns:tsip="http://schemas.thomson.com/ts/20041221/tsip" xmlns:tsxm="http://schemas.thomson.com/ts/20041221/tsxm" tsip:action="replace" tsip:cc="CA" tsip:se="2715340" tsi
p:ki="C">
  <accessions tsip:action="replace">
    <accession tsip:src="wila" tsip:type="key">CA-2715340-C</accession>
    <accession tsip:src="tscm" tsip:type="tscmKey">CA-2715340-C-20150804</accession>
  </accessions>
  <claimed tsip:action="replace">
    <claimsTsxm tsip:lang="en">
      <tsxm:heading tsxm:align="left">We Claim:</tsxm:heading>
      <claimTsxm tsip:no="1" tsxm:num="1" tsip:type="main">1.  power.</claimTsxm>
    </claimsTsxm>
  </claimed>
</patent>
<patent xmlns="http://schemas.thomson.com/ts/20041221/tsip" xmlns:tsip="http://schemas.thomson.com/ts/20041221/tsip" tsip:action="replace" tsip:cc="CA" tsip:se="2715340" tsip:ki="C">                                                
  <accessions xmlns="http://schemas.thomson.com/ts/20041221/tsip" xmlns:tsip="http://schemas.thomson.com/ts/20041221/tsip" tsip:action="replace">                                                                                     
    <accession tsip:src="wila" tsip:type="key">CA-2715340-C</accession>                                                                                                                                                               
    <accession tsip:src="tscm" tsip:type="tscmKey">CA-2715340-C-20150804</accession>                                                                                                                                                  
  </accessions>                                                                                                                                                                                                                       
  <claimed xmlns="http://schemas.thomson.com/ts/20041221/tsip" xmlns:tsip="http://schemas.thomson.com/ts/20041221/tsip" tsip:action="replace">                                                                                        
    <claimsTsxm tsip:lang="en">                                                                                                                                                                                                       
      <tsxm:heading xmlns:tsxm="http://schemas.thomson.com/ts/20041221/tsxm" tsxm:align="left">We Claim:</tsxm:heading>                                                                                                               
      <claimTsxm tsip:no="1" xmlns:tsxm="http://schemas.thomson.com/ts/20041221/tsxm" tsxm:num="1" tsip:type="main">1.  power.</claimTsxm>                                                                                            
    </claimsTsxm>                                                                                                                                                                                                                     
  </claimed>                                                                                                                                                                                                                          
</patent>                                                                                                                                                                                                                             

Det er ikke identisk med din original, men har ikke længere navneområdets korruption. Om du kan gøre det i din rigtige forespørgsel, og om jokertegningen forårsager problemer for det, er en anden sag...




  1. Sådan ændres ordrestartnummer i Magento

  2. MySQL fjerner indledende nul fra heltalskolonnen

  3. Zeppelin Oracle SQL-forespørgsel kører forud

  4. sql update int kolonne baseret på tidligere int kolonne