SAP PI PO XSLT Mapping of Adapter-Specific Message Attributes

适配器特定消息属性的 XSLT 映射

XSLT Mapping of Adapter-Specific Message Attributes 

The message header of an XI message contains a header for adapter-specific message attributes that the sender adapter can use to write additional information to the message header. This enables sender adapters to write information that is not known until runtime to the message (see: Adapter-Specific Attributes in the Message Header).

To change the fields of this header in a mapping program, you usually use a Java mapping program (see also: Java Mapping of Adapter-Specific Attributes). Nevertheless, you can also use the relevant classes as a Java enhancement in an XSLT program.

In this example, the Java classes for a mapping of the message header for adapter-specific message attributes are used in an XSLT program to change the parameter Directory of the file adapter. The XSLT program is structured thus:

       1.      First, the required Java classes are declared as namespaces:

○     java.util.map to be able to access the constants of the mapping runtime. The header for the adapter-specific message attributes is saved as a Map with the name DynamicConfiguration.

○     com.sap.aii.mapping.api.DynamicConfiguration and com.sap.aii.mapping.api.DynamicConfigurationKey for the header mapping.

       2.      The parameter name inputparam is defined and enables you to transfer the constants of the StreamTransformationConstants class to the Java runtime.

       3.      To change the header for the dynamic configuration, the XSLT program gets the Map for the header, creates a key for the parameter Directory in the file adapter, gets the current value for this parameter by using the method get(), links this directory path with the XSLT method concat and replaces the value by using the method put().

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:map="java:java.util.Map"
  xmlns:dyn="java:com.sap.aii.mapping.api.DynamicConfiguration"
  xmlns:key="java:com.sap.aii.mapping.api.DynamicConfigurationKey">
  <xsl:output indent="no" />
  <xsl:param name="inputparam"/>
  <xsl:template match="/">
    <!-- change dynamic configuration -->
    <xsl:variable name="dynamic-conf" select="map:get($inputparam, 'DynamicConfiguration')" />
    <xsl:variable name="dynamic-key" select="key:create('http://sap.com/xi/XI/System/File', 'Directory')" />
    <xsl:variable name="dynamic-value" select="dyn:get($dynamic-conf, $dynamic-key)" />
    <xsl:variable name="new-value" select="concat($dynamic-value, 'subfolder\')" />
    <xsl:variable name="dummy" select="dyn:put($dynamic-conf, $dynamic-key, $new-value)" />
    <!-- copy payload -->
    <xsl:copy-of select="." />
  </xsl:template>
</xsl:stylesheet>

适配器特定消息属性的 XSLT 映射
XI 消息的消息头包含特定于适配器的消息属性的头,发送方适配器可以使用该头将附加信息写入消息头。这使发送方适配器能够将直到运行时才知道的信息写入消息(请参阅:消息头中的适配器特定属性)。

要在映射程序中更改此标头的字段,通常使用 Java 映射程序(另请参阅:适配器特定属性的 Java 映射)。不过,您也可以将相关类用作 XSLT 程序中的 Java 增强。

在此示例中,用于映射特定于适配器的消息属性的消息头的 Java 类在 XSLT 程序中用于更改文件适配器的参数 Directory。 XSLT 程序的结构如下:

       1.首先,将所需的Java类声明为命名空间:

○ java.util.map 能够访问映射运行时的常量。特定于适配器的消息属性的标头保存为名为 DynamicConfiguration 的 Map。

○ com.sap.aii.mapping.api.DynamicConfiguration 和 com.sap.aii.mapping.api.DynamicConfigurationKey 用于标头映射。

       2. 定义了参数名称 inputparam,使您能够将 StreamTransformationConstants 类的常量传输到 Java 运行时。

       3. 要更改动态配置的标头,XSLT 程序获取标头的 Map,为文件适配器中的参数 Directory 创建一个键,使用 get() 方法获取此参数的当前值,链接此使用 XSLT 方法 concat 的目录路径,并使用 put() 方法替换该值。

XSLT Mapping Program with Java Enhancement
XSLT Mapping of Adapter-Specific Message Attributes 适配器特定消息属性的 XSLT 映射icon-default.png?t=M276https://help.sap.com/docs/SAP_NETWEAVER_701/6f32f7136c4b101499aac9e4a5643c40/4303fe1bdc7821ade10000000a1553f6.html?locale=en-US

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SAP爱好者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值