如何删除PI XSLT映射中的xsi:属性?

问题描述 投票:0回答:1

我在SAP NW PI(流程集成)上工作,目前我们有一个来自第三方系统的入站Payload,使用SOAP的Payload类似于

<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>

第一个问题是命名空间的每个元素都应该有前缀ns0,这个问题用下面的XSLT Mapping解决了。

        <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>

现在我的问题是要从元素中删除xsi属性,我应该如何完成这个任务?

xslt sap sap-xi xsi sap-pi
1个回答
0
投票

要删除所有 xsi: 属性,你可以使用一个空模板来匹配它

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

但你的XMLXSLT也有其他问题。

  • 命名空间不是绝对的,所以,比如说,把命名空间改成类似于 http://C4C_Pre_Call_Preparation_Part2.
  • 您的 <xsl:element name="ns0:{name()}" ...> 宁可用 local-name() 何止 name().
  • 你忘记为 xsi 前缀。通常情况下 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 是用于。
© www.soinside.com 2019 - 2024. All rights reserved.