2016-04-20 28 views
0

IBM Datapower中有两个XSL转换依次进行。首先包含url打开的调用并返回一些BINARY NODE。该节点包含带有JSON文档的.gz存档。第二变换是如下:IBM Datapower上的XSLT之后的JSON输出

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

二进制节点首先变换为Base64串(input64 $),然后通过解包DP:膨胀的功能。 $ outputJson变量肯定包含一个JSON字符串。但尽管指令为<xsl:copy-of select="$outputJson"/>,但XSLT输出仍为空字符串。我怎样才能得到输出的JSON?

回答

0

要从XSLT二进制,你需要把它包在“输出”输出的东西:

<object> 
    <message> 
     <xsl:copy-of select="$outputJson"/> 
    </message> 
</object> 

我会考虑但使用上下文变量,而不是:

<dp:set-variable name="'var://context/JSON/output'" value="$outputJson" />