I'm trying to parse a to xml converted SOAP request response. Please notice that this is my first time using this kind of query. It has the following structure:
<soap:Body>
<ns2:findDocumentsResponse xmlns:ns2="http://www.datengut.de">
<ecmDocumentInfo>
<id>53CA3873CCFCC44FB5FE99047E5ED04E000000000000</id>
<fields>
<entry>
<key>SYSFILENAMES</key>
<value>
<name>SYSFILENAMES</name>
<type>STRING</type>
<values xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">test_file1.pdf</values>
<values xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">test_file2.pdf</values>
<values xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">test_file3.pdf</values>
<values xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">test_file4.pdf</values>
<isMulti>true</isMulti>
</value>
</entry>
</fields>
....
The SQL Query I'm using is the following:
SELECT
t."key", f."value"
FROM
XMLTABLE(
xmlnamespaces('http://schemas.xmlsoap.org/soap/envelope/' as "soap",'http://www.datengut.de' as "ns2"),
'/soap:Envelope/soap:Body/ns2:findDocumentsResponse/ecmDocumentInfo/fields/entry'
PASSING xmltype.createXML('[see structure above]')
COLUMNS
"key" varchar2(4000) PATH 'key',
"path" XMLType path 'value'
) t
CROSS JOIN XMLTABLE(
'value'
PASSING t."path"
COLUMNS
"value" varchar2(4000) PATH '.'
) f
The Output I'm receiving:
KEY VALUE
------------------- ---------------------------------------
SYSFILENAMES SYSFILENAMESSTRINGtest_file1.pdftest_file2.pdftest_file3.pdftest_file4.pdftrue
The Output I'm expecting to receive:
KEY VALUE
------------------- ---------------------------------------
SYSFILENAMES test_file1.pdf
SYSFILENAMES test_file2.pdf
SYSFILENAMES test_file3.pdf
SYSFILENAMES test_file4.pdf
When I change the line:
"value" varchar2(4000) PATH '.'
to
"value" varchar2(4000) PATH 'values'
I receive the "ORA-19279: XPTY0004 - XQuery dynamic type mismatch: expected singleton sequence" error message. The error does not appear when PATH is '.' but then I receive every value of the value entry in the same line. I just want to display the filenames like shown in the expected result section. How do I cross join the second XMLTABLE f to receive my expected output. Many thanks in advance.