We have a XML-file containing at the top of the XML, inside a node, some content that makes xmltable to fail to parse the file (Invantive Query Tool v20.2.205).
In our case the simplified file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.054.001.02"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:camt.054.001.02 camt.054.001.02.xsd">
<BkToCstmrDbtCdtNtfctn>
<GrpHdr>
<MsgId>OIA20220402030407</MsgId>
<CreDtTm>2022-04-02T03:04:07</CreDtTm>
<MsgPgntn>
<PgNb>1</PgNb>
<LastPgInd>true</LastPgInd>
</MsgPgntn>
</GrpHdr>
</BkToCstmrDbtCdtNtfctn>
</Document>
Here is the SQL-statement:
select *
from files@Os('C:\', '*.xml', false) fle
join read_file_text@Os(fle.file_path) rfe
join xmltable
( '/Document/BkToCstmrDbtCdtNtfctn/GrpHdr'
passing rfe.file_contents
columns identification varchar2 path 'MsgId'
) xml
With the XML above, the statement will return no result.
But expected is: OIA20220402030407
Workaround
The outcome is correct when we remove the following content from the <Document>
node
xmlns="urn:iso:std:iso:20022:tech:xsd:camt.054.001.02"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:camt.054.001.02 camt.054.001.02.xsd
Result:
The XML in that case is:
<?xml version="1.0" encoding="UTF-8"?>
<Document>
<BkToCstmrDbtCdtNtfctn>
<GrpHdr>
<MsgId>OIA20220402030407</MsgId>
<CreDtTm>2022-04-02T03:04:07</CreDtTm>
<MsgPgntn>
<PgNb>1</PgNb>
<LastPgInd>true</LastPgInd>
</MsgPgntn>
</GrpHdr>
</BkToCstmrDbtCdtNtfctn>
</Document>