简体   繁体   English

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

[英]How to remove xsi: attributes in PI XSLT mapping?

I am working on SAP NW PI (Process Integration) at current we have a inbound Payload from a Third party System using SOAP the Payload is similar to我目前正在研究 SAP NW PI(流程集成),目前我们有来自第三方系统的入站有效负载,使用 SOAP 有效负载类似于

<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.命名空间应该在每个元素上都有前缀 ns0 的第一个问题。 this problem was fixed using below XSLT Mapping使用下面的 XSLT 映射解决了这个问题

        <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?现在我的问题是从元素中删除 xsi 属性,我应该如何做到这一点?

To remove all xsi: attributes you can use an empty template matching it要删除所有xsi:属性,您可以使用与之匹配的空模板

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

But there are also other issues with your XML/XSLT:但是您的 XML/XSLT 还存在其他问题:

  • The namespace is not absolute, so, for example, change the namespace to something like http://C4C_Pre_Call_Preparation_Part2 .命名空间不是绝对的,因此,例如,将命名空间更改为类似http://C4C_Pre_Call_Preparation_Part2
  • Your <xsl:element name="ns0:{name()}" ...> should rather use a local-name() than a name() .您的<xsl:element name="ns0:{name()}" ...>应该使用local-name()不是name()
  • You forgot to specify a namespace for the xsi prefix.您忘记为xsi前缀指定命名空间。 Usually xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" is used for that.通常xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"用于此目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM