Sam CMS
Sam CMS

Reputation: 11

XML output in Mapforce - Add non-default namespace in element without prefix

Hope I can get some help here on this requirement that I've been stuck on for a few days now.

I'm trying to produce a XML output file for SWIFT confirming to their ISO20022 requirements. The target output has the structure below and note the specific namespace defined for AppHdr, which do not include prefixes.

<DataPDU xmlns="urn:swift:saa:xsd:saa.2.0">
<Header>
</Header>
<Body>
<AppHdr xmlns="urn:iso:std:iso:20022:tech:xsd:head.001.001.01">
....element
</AppHdr>
</Body>
</Header>
</DataPDU>

But when I created a schema with DataPDU as root element, and manually add namespaces in Mapforce to AppHdr, taking note that prefix is mandatory and I then connected a blank string to it. The resulting output is as below:

<DataPDU xmlns="urn:swift:saa:xsd:saa.2.0">
<Header>
</Header>
<Body>
<AppHdr xmlns="urn:iso:std:iso:20022:tech:xsd:head.001.001.01">
<Fr ***xmlns="urn:swift:saa:xsd:saa.2.0"***>
<FIId>
<FinInstnId>
<BICFI>BIC</BICFI>
</FinInstnId>
</FIId>
</Fr>
</AppHdr>
</Body>
</Header>
</DataPDU>

I'd like to seek your help to understand how can I achieve without the xmlns="urn:swift:saa:xsd:saa.2.0 namespace included in it's child element of . If this cannot be achieved via Mapforce, alterations to the XML schema used is also an option but I have limited XML knowledge so would need to ask for help from the kind hearted souls here too.

Appreciate any help I can get on this.

Upvotes: -1

Views: 168

Answers (1)

Michael Kay
Michael Kay

Reputation: 163262

I don't know the SWIFT schema (or MapForce), but from your example it looks as if it's not only the AppHdr element that needs to be in namespace urn:iso:std:iso:20022:tech:xsd:head.001.001.01, but all its children and descendants as well (a default namespace declaration on the AppHdr implicitly applies to all its descendants).

But it looks as if you have created these descendant elements in namespace urn:swift:saa:xsd:saa.2.0, which is why that namespace declaration has been added to the Fr element.

The golden rule is to think about what namespace each element should be in, and let the namespace declarations take care of themselves.

Upvotes: 0

Related Questions