java-apache fop嵌入式文件声明中的Xslt变量

前端之家收集整理的这篇文章主要介绍了java-apache fop嵌入式文件声明中的Xslt变量 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我的xsl文件中有一个嵌入式文件,如下所示:

@H_301_5@<xsl:template match="$pathPrefix/tns:AdditionalInfoStruct/tns:AdditionalInfo/dtsf:File"> <pdf:embedded-file filename="file.txt" src="data:text/html;base64,c2tsZGFsa2RhbnNrbHhuYXNrbGRrbGFzZGp3amRvcGFzZGpsc2RrYXNjbXNrbGNtYXNrbGQ7YXNz"/> </xsl:template>

上面的示例工作正常,但是当我想从xslt节点获取base64中的文件名和内容时,它不起作用.不起作用的示例:

@H_301_5@<xsl:template match="$pathPrefix/tns:AdditionalInfoStruct/tns:AdditionalInfo/dtsf:File"> <xsl:variable name="name" select="current()/dtsf:Name"/> <xsl:variable name="content" select="current()/dtsf:Content"/> <pdf:embedded-file filename="$name" src="data:text/html;base64,$content"/> </xsl:template>

为什么我不能在pdf:embedded标记中的文件名和src参数中使用变量? Mayby我可以以编程方式将附件添加到Java中的pdf中吗?有人知道吗?

最佳答案
我会尝试这样的事情:

@H_301_5@<pdf:embedded-file> <xsl:attribute name="filename"><xsl:value-of select="$name"/></xsl:attribute> <xsl:attribute name="src">data:text/html;base64,<xsl:value-of select="$content"/></xsl:attribute> </pdf:embedded-file>

猜你在找的Java相关文章