title: Images in XSL-FO in eXist-db
body: <p>In my former question I have touched a broader problem of paths and their recognizing inside an eXist-db app.</p>
  
  <p>At the moment, I am not able to get images in to PDF files. I have tried 2 installations of eXist (2.2 and 3RC) and many possible scenarios. Of course, I have tested those pictures are reachable through the browser.</p>
  
  <p>In the source file, I have tried:</p>
  
  <pre><code>1. &lt;graphic url="img/tealover.jpg"/&gt;
  2. &lt;graphic url="/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg"/&gt;
  3. &lt;graphic url="http://46.28.111.241:8081/exist/rest/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg"/&gt;
  
  4. &lt;graphic url="url(img/tealover.jpg)"/&gt;
  5. &lt;graphic url="url(/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg)"/&gt;
  6. &lt;graphic url="url(http://46.28.111.241:8081/exist/rest/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg)"/&gt;
  
  7. &lt;graphic url="url('img/tealover.jpg')"/&gt;
  8. &lt;graphic url="url('/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg')"/&gt;
  9. &lt;graphic url="url('http://46.28.111.241:8081/exist/rest/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg')"/&gt;
  </code></pre>
  
  <p>As expected, samples 3, 6 and 9 work <strong>but</strong> only if I have them in a form of hardcoded links in the source. If I build up the links in my XSLT stylesheet, they are exactly the same in the FO file but there is nothing in the produced PDF.</p>
  
  <p>Equivalents produced in FO file:</p>
  
  <pre><code>1. &lt;fo:external-graphic src="img/tealover.jpg"/&gt;
  2. &lt;fo:external-graphic src="/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg"/&gt;
  3. &lt;fo:external-graphic src="http://46.28.111.241:8081/exist/rest/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg"/&gt;
  
  4. &lt;fo:external-graphic src="url(img/tealover.jpg)"/&gt;
  5. &lt;fo:external-graphic src="url(/db/apps/karolinum-apps/data/2015080/img/tealover.jpg)"/&gt;
  6. &lt;fo:external-graphic src="url(http://46.28.111.241:8081/exist/rest/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg)"/&gt;
  
  7. &lt;fo:external-graphic src="url('img/tealover.jpg')"/&gt;
  8. &lt;fo:external-graphic src="url('/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg')"/&gt;
  9. &lt;fo:external-graphic src="url('http://46.28.111.241:8081/exist/rest/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg')"/&gt;
  </code></pre>
  
  <p>When I hard-code those links into the source, in the stylesheet works <code>src="{@url}"</code>. When I use the short version of url everywhere (<code>url="img/tealover.jpg"</code>), in the attribute stylesheet I use</p>
  
  <pre><code>&lt;xsl:value-of select="concat('http://46.28.111.241:8081/exist/rest', $imgPath, @url)"/&gt;
  </code></pre>
  
  <p>or directly in the template</p>
  
  <pre><code>src="concat('http://46.28.111.241:8081/exist/rest', $imgPath, @url)"
  </code></pre>
  
  <p>The <code>$imgPath</code> variable is passed as a param from the application:</p>
  
  <pre><code>let $bookUri := base-uri($resource)
  let $imgPath := replace($bookUri, '[^/]*?$', '')
  </code></pre>
  
  <p>With this, links 1, 4 and 7 should work, the rest is a mess. I can copy these links in eXide and they still work in the browser.</p>
  
  <p>When I am testing, everything looks fine. In the PDF, there is still no picture. I guess there has to be a tiny detail I am missing now.</p>