I am working through a payment integration transformation. One xml payment fie can contain more than one payment. because of this there will be more than one instances of IBAN (). I need my XSLT to remove all spaces and hyphens from the one or many instances of . XML below. I have exhausted all options. as for this project this is the only art I need answers on. In the XML sample below there are two instances of IBAN. I have tried for-each, storing and removing characters in variable (ends up concat values in both elements)... any help would be great. This is sample data and not actual payment data.
<?xml version="1.0" encoding="utf-8"?> <Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <CstmrCdtTrfInitn>
<GrpHdr>
<MsgId>FILEREFT2</MsgId>
<CreDtTm>2016-07-05T14:20:07</CreDtTm>
<NbOfTxs>2</NbOfTxs>
<CtrlSum>251000.50</CtrlSum>
<InitgPty>
<Nm>Test Client</Nm>
<Id>
<OrgId>
<Othr>
<Id>CLIENT ID</Id>
</Othr>
</OrgId>
</Id>
</InitgPty>
</GrpHdr>
<PmtInf>
<PmtInfId>BATCHREF</PmtInfId>
<PmtMtd>TRF</PmtMtd>
<NbOfTxs>1</NbOfTxs>
<CtrlSum>251000.50</CtrlSum>
<PmtTpInf>
<SvcLvl>
<Cd>URGP</Cd>
</SvcLvl>
</PmtTpInf>
<ReqdExctnDt>2016-07-05</ReqdExctnDt>
<Dbtr>
<Nm>This Is My Debtor</Nm>
<PstlAdr>
<PstCd>ABCD1XXX</PstCd>
<TwnNm>London</TwnNm>
<CtrySubDvsn>Regent's Place</CtrySubDvsn>
<Ctry>GB</Ctry>
<AdrLine>10 A Street</AdrLine>
</PstlAdr>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>GB-29NWBK 601613319268 19</IBAN>
</Id>
<Ccy>GBP</Ccy>
</DbtrAcct>
<DbtrAgt>
<FinInstnId>
<BIC>NWBKGB2L</BIC>
<ClrSysMmbId>
<MmbId>601613</MmbId>
</ClrSysMmbId>
<PstlAdr>
<TwnNm>London</TwnNm>
<Ctry>GB</Ctry>
<AdrLine>London</AdrLine>
</PstlAdr>
</FinInstnId>
</DbtrAgt>
<CdtTrfTxInf>
<PmtId>
<InstrId>TRXREFT2</InstrId>
<EndToEndId>TRXREFT2</EndToEndId>
</PmtId>
<Amt>
<InstdAmt Ccy="GBP">251000.50</InstdAmt>
</Amt>
<ChrgBr>SHAR</ChrgBr>
<CdtrAgt>
<FinInstnId>
<BIC>MIDLGB22XXX</BIC>
<ClrSysMmbId>
<MmbId>404865</MmbId>
</ClrSysMmbId>
<PstlAdr>
<Ctry>GB</Ctry>
</PstlAdr>
</FinInstnId>
</CdtrAgt>
<Cdtr>
<Nm>My Creditor</Nm>
<PstlAdr>
<TwnNm>Leeds</TwnNm>
<Ctry>GB</Ctry>
<AdrLine>Palace Square</AdrLine>
</PstlAdr>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>GB-32ESSE40486562136016</IBAN>
</Id>
</CdtrAcct>
<RmtInf>
<Ustrd>Free Text- This is a CHAPS payment 12345.</Ustrd>
</RmtInf>
</CdtTrfTxInf> <CdtTrfTxInf>
<PmtId>
<InstrId>TRXREFT3</InstrId>
<EndToEndId>TRXREFT3</EndToEndId>
</PmtId>
<Amt>
<InstdAmt Ccy="GBP">1000.3</InstdAmt>
</Amt>
<ChrgBr>SHAR</ChrgBr>
<CdtrAgt>
<FinInstnId>
<BIC>MIDLGB22XXX</BIC>
<ClrSysMmbId>
<MmbId>404865</MmbId>
</ClrSysMmbId>
<PstlAdr>
<Ctry>GB</Ctry>
</PstlAdr>
</FinInstnId>
</CdtrAgt>
<Cdtr>
<Nm>My Creditor</Nm>
<PstlAdr>
<TwnNm>Leeds</TwnNm>
<Ctry>GB</Ctry>
<AdrLine>Spire Apparel</AdrLine>
</PstlAdr>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>GB32ESSE404865621360 16</IBAN>
</Id>
</CdtrAcct>
<RmtInf>
<Ustrd>Free Text- This is a FASTER payment 12345.</Ustrd>
</RmtInf>
</CdtTrfTxInf>
</PmtInf> </CstmrCdtTrfInitn> </Document>
Not sure what version of XSLT you're using, but this should cover all of them...
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:idk="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="idk:IBAN/text()">
<xsl:value-of select="translate(.,'- ','')"/>
</xsl:template>
</xsl:stylesheet>
It uses the identity transform and translate()
.