将图像 url 动态设置到 xsl 文件中

发布于 2024-09-25 21:19:13 字数 902 浏览 1 评论 0原文

我想创建一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

后eg是否自 2024-10-02 21:19:13

您可以将 {$imageUrl} 替换为 {/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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文