将图像 url 动态设置为 xsl 文件 [英] Set a image url dynamically into a xsl file
本文介绍了将图像 url 动态设置为 xsl 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个 xsl 文件(用于使用 xml 将 xslt 转换为 xsl:fo)如何显示 url 存储在 xml 文件中的图像?我可以使用变量
I want to create an xsl file (for a xslt transformation to xsl:fo using an xml) How can I display a image whose url is stored in the xml file? I can use variables
<fo:block-container top="5mm" height="20mm" left="0mm" width="75mm">
<fo:block margin-top="10mm" margin-left="50mm">
<fo:external-graphic display-align="center" src="url('{$imageUrl}')" content-width="75mm"></fo:external-graphic>
</fo:block>
</fo:block-container>
但是如何从 xml 文件中的标记设置变量的值?
But how can I set the variable's value from a tag from the xml file?
来自评论的示例 XML:
Sample XML from comment:
<?xml version="1.0" encoding="UTF-8" ?>
<doc>
<title>Simple test</title>
<image>
<i>colour_logo.jpg</i>
</image>
<body>
<question>
<p>Is the sky blue?</p>
</question>
<question>
<p>Is the grass blue?</p>
</question>
</body>
</doc>
推荐答案
您可以将 {$imageUrl}
替换为 {/doc/image/i}
.>
You can replace {$imageUrl}
with {/doc/image/i}
.
<fo:block-container top="5mm" height="20mm" left="0mm" width="75mm">
<fo:block margin-top="10mm" margin-left="50mm">
<fo:external-graphic display-align="center" src="url('{/doc/image/i}')" content-width="75mm"></fo:external-graphic>
</fo:block>
</fo:block-container>
这篇关于将图像 url 动态设置为 xsl 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文