将图像 url 动态设置到 xsl 文件中
我想创建一个 xsl 文件(用于使用 xml 将 xslt 转换为 xsl:fo) 如何显示 url 存储在 xml 文件中的图像? 我可以使用变量
<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 文件的标签设置变量的值?
评论中的 XML 示例:
<?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>
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>
But how can I set the variable's value from a tag from the xml file?
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将
{$imageUrl}
替换为{/doc/image/i}
。You can replace
{$imageUrl}
with{/doc/image/i}
.