XQuery and SEPA style XML

66 views Asked by At

I'm trying to query a XML that is used to send the SEPA file. I'm new with xquery and in the Base X program does not work this sentence

for $t in /CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf return $t/Cdtr/Nm/node()

¿Can anyone help me?

thanks a lot

2

There are 2 answers

0
Michael Kay On

Presumably by "it doesn't work", you mean it returns nothing, with no error message?

We can't tell why that is without seeing the source document being queried. As Martin says, namespaces are a very likely culprit (on the basis that you're new to XQuery and that's what catches most people out).

Note that you can simplify your query to the simple path expression

/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf/Cdtr/Nm/node()
0
Martin Honnen On

It might be that your elements are in the namespace urn:iso:std:iso:20022:tech:xsd:pain.001.001.11 so

declare default element namespace 'urn:iso:std:iso:20022:tech:xsd:pain.001.001.11';

should help to select elements from that namespace; the schema I have found also suggests the root element is Document so /Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf is more likely to work.