I have the following self-contained testcase: (run on Oracle 12.1 via Oracle 11.2.0.3 client)
SET SERVEROUTPUT ON
DECLARE
xmldocX XMLType;
r1X VARCHAR2(100);
r2X VARCHAR2(100);
BEGIN
xmldocX:=XMLType('<xmlZdroj>
<zdrojdok typ="ELDP09">
<eldp09 xmlns="http://schemas.cssz.cz/ELDP09" sqnr="1" yer="2009" typ="01" dep="660" nam="HB"></eldp09>
</zdrojdok>
</xmlZdroj>');
SELECT sqnr,yer
INTO r1X,r2X
FROM xmltable(XMLNamespaces('http://schemas.cssz.cz/ELDP09' AS "xx"),
'/xx:xmlZdroj/xx:zdrojdok/xx:eldp09'
PASSING xmldocX
COLUMNS
sqnr VARCHAR2(10) PATH '@xx:sqnr',
yer VARCHAR2(10) PATH '@xx:yer'
);
DBMS_OUTPUT.PUT_LINE('result: '||nvl(r1X,'null')||' '||nvl(r2X,'null'));
END;
/
It fails with "no data found". If I remove the xmlns specifications in the ELDP09 element and in XMLTABLE, the code works and gives the expected result. Can you please tell me how to achieve the same with the namespace present? I also tried to use the default namespace specification in XMLTABLE, but it was no use either.