xml - Oracle XMLQuery is corrupting the namespace -


oracle version 11.2

below cut down version of xmlquery i'm running on xmltype column. when run query, parses , recreates stored xml, tsxm namespace (that not equal default namespace ) gets changed. query nothing , rewritten, real (much bigger) query uses same methodology why i'm posting question in format. if change tsxm namespace definition same default namespace :

xmlns:tsxm="http://schemas.thomson.com/ts/20041221/tsip" 

then problem goes away, in real application not possible.

create table:

create table xml_document_tmp (   document_id   number(12)                      not null,   xml_data      sys.xmltype                     not null,   created_date  timestamp(6)                    not null ); 

insert data:

insert xml_document_tmp (document_id,created_date,xml_data) values(1,sysdate,'<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" tsip: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> 

');

run xmlquery:

with tmptable ( select * xml_document_tmp cm ) select tt.xml_data , 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/@*}       {         $i in $m/patent/*             return    $i       }       </patent>'              passing tt.xml_data "m"   returning content) newxml   tmptable tt  tt.document_id in (1); 

returns:

<patent xmlns="http://schemas.thomson.com/ts/20041221/tsip"    xmlns:syspfx_at="http://schemas.thomson.com/ts/20041221/tsip" syspfx_at:action="replace" syspfx_at:cc="ca" syspfx_at:se="2715340" syspfx_at:ki="c"><accessions xmlns="http://schemas.thomson.com/ts/20041221/tsip" action="replace"> <accession src="wila" type="key">ca-2715340-c</accession> <accession src="tscm" type="tscmkey">ca-2715340-c-20150804</accession> </accessions> <claimed xmlns="http://schemas.thomson.com/ts/20041221/tsip" action="replace"> <claimstsxm lang="en"> <syspfx_1:heading xmlns:syspfx_1="http://schemas.thomson.com/ts/20041221/tsxm" syspfx_1:align="left">we claim:</syspfx_1:heading> <claimtsxm no="1" xmlns:syspfx_1="http://schemas.thomson.com/ts/20041221/tsxm" syspfx_1:num="1" type="main">1.  power.</claimtsxm> </claimstsxm> </claimed> </patent> 

so , question is, causing tsxm namespace declaration changed syspfx_at , tsxm namespace prefix xmlns:syspfx_1?

any ideas appreciated.

this appears expected behaviour, according my oracle support doc id 2060374.1. bit of experimentation seems wildcarding namespace in xpath stops happening; so:

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

with original data (in 11.2.0.4), , serialized format more readably:

 tmptable ( select * 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/@*}       {         $i in $m/*:patent/*             return    $i       }       </patent>'              passing tt.xml_data "m"   returning content)  varchar2(4000) indent size = 2) ewxml   tmptable tt  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>                                                                                                                                                                                                                              

that isn't identical original doesn't have namespace corruption more. whether can in real query, , whether wildcarding causes issues that, matter...


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -