2016-04-20 26 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" />