英文:
How to insert image data from xml into xsl template?
问题
我正在使用 Apache-FOP,使用 xsl 模板将 xml 转换为 PDF。
我有以下的 xml 结构:
<image>
<type>image/png</type>
<data>iVBORw0KGgoAAAANS...</data>
</image>
以及如下的模板:
<fo:external-graphic content-height="60pt" height="auto" width="auto"
src="url(data:<type>;base64,<data>)"/>
如何将数据和类型插入模板中?
从 xml 插入图像作为数据的更好方法是什么?
英文:
I am converting xml to PDF with an xsl template, using Apache-FOP.
I have the following xml structure:
<image>
<type>image/png</type>
<data>iVBORw0KGgoAAAANS...</data>
</image>
And a template like:
<fo:external-graphic content-height="60pt" height="auto" width="auto"
src="url(data:<type>;base64,<data>)"/>
How do I insert data and type into the template?
Is there a better way to insert image as data from an xml?
答案1
得分: 1
假设您的代码位于 xsl:template match="image" 内部,要从子元素填充属性值,请使用属性值模板 src="url(data:{type};base64,{data})"。
英文:
Assuming your code is inside of an xsl:template match="image", to populate the attribute value from the child elements, use attribute value templates src="url(data:{type};base64,{data})".
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论