[英]JSON output after XSLT on IBM Datapower
There is two XSL transformations in IBM Datapower one after another. IBM Datapower中有两个XSL转换。 First of them contains url-open call and returns some BINARY NODE .
其中第一个包含url-open调用并返回一些BINARY NODE 。 That node contains .gz archive with JSON doc inside.
该节点包含带有JSON doc的.gz存档。 Second transformation is below:
第二次转型如下:
<xsl:output method="text" encoding="utf-8" indent="yes" media-type="application/json"/>
<dp:input-mapping type="ffd" href="local:///binaryNode.ffd"/>
<xsl:variable name="input64" select="dp:binary-encode(/object/message/node())"/>
<xsl:template match="/">
<xsl:message terminate="no" dp:priority="alert" dp:type="all">input64<xsl:copy-of select="$input64"/></xsl:message>
<xsl:variable name="outputJson" select="dp:inflate($input64, 'gzip')"/>
<xsl:copy-of select="$outputJson"/>
</xsl:template>
Binary node first transforms to Base64 string ($input64) and then unpacks by dp:inflate function. 二进制节点首先转换为Base64字符串($ input64),然后通过dp:inflate函数解包。 $outputJson variable definitely contains a JSON string.
$ outputJson变量肯定包含一个JSON字符串。 But XSLT output is empty string despite of instruction
<xsl:copy-of select="$outputJson"/>
. 但是,尽管指令
<xsl:copy-of select="$outputJson"/>
XSLT输出<xsl:copy-of select="$outputJson"/>
空字符串。 How can I get a JSON on output? 如何在输出中获得JSON?
To output something from a XSLT binary you need to wrap it in the "output": 要从XSLT二进制文件输出内容,您需要将其包装在“输出”中:
<object>
<message>
<xsl:copy-of select="$outputJson"/>
</message>
</object>
I would however consider using a context variable instead: 不过我会考虑使用上下文变量:
<dp:set-variable name="'var://context/JSON/output'" value="$outputJson" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.