Set graphical url dynamically to xsl file

I want to create an xsl file (to convert xslt to xsl: fo using xml) How can I display an image whose URL is stored in an 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 value of a variable from a tag from an xml file?

XML example from a 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>
+2
source share
1 answer

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>
+3
source

Source: https://habr.com/ru/post/1769363/


All Articles