Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Extract value from XML with "unknown" namespace

Marwim4 days ago

The ISO 20022 standard allows to wrap an XML in a container that also contains the hash value of the XML.

It should be quite simple to extract the hash and the XML from this container but the container has different namespaces for different namespaces of the XML. Every SQL/PLSQL technic I use needs the namespace of the container to extract the value. Is there a way to get the hash and the XML without providing a namespace?

An example: <conxml> is the container <Document> is the XML part and <HashValue> the hash I need

WITH x AS (
SELECT 	XMLTYPE('
<conxml xmlns="urn:conxml:xsd:container.nnn.003.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:conxml:xsd:container:nnn.003.02 container.nnn.003.02.xsd">
    <CreDtTm>2020-04-23T12:38:59</CreDtTm>
    <MsgPain001>
        <HashValue>CFB106B1FE19CCC0F6A1E8605507566EF91F3A74EDAFCA927DBFF150A5BD7307</HashValue>
        <HashAlgorithm>SHA256</HashAlgorithm>
        <Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.003.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.003.03 pain.001.003.03.xsd">
            <CstmrCdtTrfInitn>
                <GrpHdr>
                    <MsgId>1000119214</MsgId>
                    <CreDtTm>2020-04-23T12:38:59</CreDtTm>
                    <NbOfTxs>1</NbOfTxs>
                    <CtrlSum>10.00</CtrlSum>
                    <InitgPty>
                        <Nm>My Company</Nm>
                    </InitgPty>
                </GrpHdr>
                <PmtInf>
                    <PmtInfId>123</PmtInfId>
                    <PmtMtd>TRF</PmtMtd>
                    <NbOfTxs>1</NbOfTxs>
                    <CtrlSum>10.00</CtrlSum>
                    <PmtTpInf>
                        <SvcLvl>
                            <Cd>SEPA</Cd>
                        </SvcLvl>
                    </PmtTpInf>
                    <ReqdExctnDt>2020-03-17</ReqdExctnDt>
                    <Dbtr>
                        <Nm>Some Name</Nm>
                        <PstlAdr>
                            <Ctry>DE</Ctry>
                            <AdrLine>Muenchen</AdrLine>
                        </PstlAdr>
                    </Dbtr>
                    <DbtrAcct>
                        <Id>
                            <IBAN>DE20000000000000000000</IBAN>
                        </Id>
                        <Ccy>EUR</Ccy>
                    </DbtrAcct>
                    <DbtrAgt>
                        <FinInstnId>
                            <BIC>BYLADEMMXXX</BIC>
                        </FinInstnId>
                    </DbtrAgt>
                    <ChrgBr>SLEV</ChrgBr>
                    <CdtTrfTxInf>
                        <PmtId>
                            <InstrId>01-0100200000032020</InstrId>
                            <EndToEndId>0020000003</EndToEndId>
                        </PmtId>
                        <Amt>
                            <InstdAmt Ccy="EUR">10.00</InstdAmt>
                        </Amt>
                        <CdtrAgt>
                            <FinInstnId>
                                <BIC>ABCDEFGHIJK</BIC>
                            </FinInstnId>
                        </CdtrAgt>
                        <Cdtr>
                            <Nm>test CT</Nm>
                        </Cdtr>
                        <CdtrAcct>
                            <Id>
                                <IBAN>DE90000000000000000000</IBAN>
                            </Id>
                        </CdtrAcct>
                        <RmtInf>
                            <Ustrd>Whatever</Ustrd>
                        </RmtInf>
                    </CdtTrfTxInf>
                </PmtInf>
            </CstmrCdtTrfInitn>
        </Document>
    </MsgPain001>
</conxml>
') myXML
FROM 	dual
)
SELECT  y.Document
       ,y.HashValue
FROM    x
       ,XMLTABLE(
            XMLNAMESPACES(DEFAULT 'urn:conxml:xsd:container.nnn.003.02'),
            '/'
            PASSING x.myXML
            COLUMNS HashValue           VARCHAR2(64)    PATH '//HashValue'
                   ,Document            XMLTYPE         PATH '//Document'
                  ) y
This post has been answered by Barbara Boehmer on Oct 27 2025
Jump to Answer
Comments
Post Details
Added 4 days ago
6 comments
99 views