Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables 将图像url动态设置到xsl文件中_Variables_Xsl Fo - Fatal编程技术网

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

Variables 将图像url动态设置到xsl文件中,variables,xsl-fo,Variables,Xsl Fo,我想创建一个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="cent

我想创建一个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>

简单测试
color_logo.jpg
天空是蓝色的吗

草是蓝色的吗?


您可以将
{$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>

示例XML将非常有用。您可以在XSLT中使用XPATH从XML获取图像的URL/路径,但是如果没有一些示例XML,就很难给出XPATH-Simple test-color\u logo.jpg---是天蓝色吗?

-是草蓝色吗