Skip to Content
0
Jan 24, 2023 at 03:45 AM

[SAP CPI]: Remove Namespace in XSLT

1159 Views Last edit Jan 24, 2023 at 03:45 AM 2 rev


Hi Experts,

I have the below input XML from the Source system. But they are sending with a namespace, so I would like to remove it.

I know that I can use the filter/groovy step before XSLT mapping to remove the namespace. But, I would like to use XSLT to remove the namespace to avoid unnecessary message steps.

Source XML:

<GoodsReceiptHeader xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.abc.com/defghij/2011/11">
	<TimeOfDelivery>2023-01-06T10:19:00</TimeOfDelivery>
	<ReceiptId>543221</ReceiptId>
	<GoodsReceiptUnits>
		<GoodsReceiptUnit>
			<Barcode>12334567890</Barcode>
			<Status>A</Status>
		</GoodsReceiptUnit>
		<GoodsReceiptUnit>
			<Barcode>0987654321</Barcode>
			<Status>A</Status>
		</GoodsReceiptUnit>
	</GoodsReceiptUnits>
</GoodsReceiptHeader><br>

XSLT:

<strong><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cpi="http://sap.com/it/" exclude-result-prefixes="cpi" version="3.0">
    <xsl:param name="RCVPRN"/>
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:strip-space elements="*"/>
	<xsl:mode on-no-match="shallow-copy"/>
	<xsl:template match="/GoodsReceiptHeader">
		<ZWPUWBW01>
			<IDOC>
				*
				*
				*
				*
				*
			</IDOC>
		</ZWPUWBW01>
	</xsl:template>
</xsl:stylesheet></strong><b><br></b>

Any leads will be really helpful.

Regards,

Pavan