Priyesh Shah
Priyesh Shah

Reputation: 1

How to remove xsi: attributes in PI XSLT mapping?

I am working on SAP NW PI (Process Integration). We have an inbound payload from a third-party system using SOAP. The payload is similar to this:

<GetReportBlock_C4C_-_Pre_Call_Preparation_Part2Response xmlns="C4C_Pre_Call_Preparation_Part2">
     <headers>
        <row>
           <cell xsi:type="xsd:string">Account</cell>
           <cell xsi:type="xsd:string">Product Group - Key</cell>
           <cell xsi:type="xsd:string">Product Group - Medium Text</cell>
           <cell xsi:type="xsd:string">Gross Sales (USD)</cell>
        </row>
     </headers>
     <table>
        <row>
           <cell xsi:type="xsd:string" xsi:nil="true"/>
           <cell xsi:type="xsd:string" xsi:nil="true"/>
           <cell xsi:type="xsd:string" xsi:nil="true"/>
           <cell xsi:type="xsd:double" xsi:nil="true"/>
        </row>
     </table>
     <user>XXX</user>
     <documentation>C4C - Pre Call Preparation_Part2</documentation>
     <documentname>C4C Pre Call Preparation - Part_2</documentname>
     <lastrefreshdate>2018-06-08T10:21:41.0</lastrefreshdate>
     <creationdate>2018-05-29T10:33:25.438</creationdate>
     <creator>XXX</creator>
     <isScheduled>XXX</isScheduled>
     <tableType>XXXX</tableType>
     <nbColumns>X/nbColumns>
     <nbLines>X</nbLines>
  </GetReportBlock_C4C_-_Pre_Call_Preparation_Part2Response>

The first problem that the namespace should have prefix ns0 on every element. This problem was fixed using below XSLT mapping (notice "how should I accomplish this"):

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="C4C_Pre_Call_Preparation_Part2">
    <xsl:output omit-xml-declaration="yes" indent="yes"/>
    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="*">
        <xsl:element name="ns0:{name()}" namespace="C4C_Pre_Call_Preparation_Part2">
            <xsl:copy-of select="namespace::*"/>
            <xsl:apply-templates select="node()|@*"/, how should I accomplish this?>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

Now my problem is to remove xsi attributes from elements, how should I accomplish this? (see above notice in XSLT code)

Upvotes: 0

Views: 1865

Answers (1)

zx485
zx485

Reputation: 29052

To remove all xsi: attributes you can use an empty template matching it

<xsl:template match="@xsi:*" />

But there are also other issues with your XML/XSLT:

  • The namespace is not absolute, so, for example, change the namespace to something like http://C4C_Pre_Call_Preparation_Part2.
  • Your <xsl:element name="ns0:{name()}" ...> should rather use a local-name() than a name().
  • You forgot to specify a namespace for the xsi prefix. Usually xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" is used for that.

Upvotes: 0

Related Questions