XSLT-2.0:如何使用BASE64String创建文本文件?

时间:2017-03-13 05:50:22

标签: xml xslt base64 xslt-2.0

我已经使用这个XSLT模板将base64string解码为字符串的方式达到了一半:

<xsl:call-template name="b64:decode">
  <xsl:with-param name="base64String" select="'aGVsbG9fZHVkZS1hd2Vzb21lLnJ1'"></xsl:with-param>
</xsl:call-template>
  

我已经理解使用这个函数我们可以解码base64string但是

我有以下XML结构

<document>
  <reference>
    <text mediaType="text/plain" representation="B64">
      <reference value="Attachment For Sambar.txt" />
            aGVsbG9fZHVkZS1hd2Vzb21lLnJ1         
    </text>
</document>

如何使用.txt作为文件名从此XML生成<reference value="Attachment For Sambar.txt">个文件

1 个答案:

答案 0 :(得分:0)

你可以写一个模板

<xsl:template match="document/reference/text[@mediaType = 'text/plain' and @representation = 'B64']">
  <xsl:result-document href="reference/@value">
    <xsl:value-of select="bin:decode-string(xs:base64Binary(.))" xmlns:bin="http://expath.org/ns/binary"/>
  </xsl:result-document>
</xsl:template>