xslt - Images in XSL-FO in eXist-db -


in former question have touched broader problem of paths , recognizing inside exist-db app.

at moment, not able images in pdf files. have tried 2 installations of exist (2.2 , 3rc) , many possible scenarios. of course, have tested pictures reachable through browser.

in source file, have tried:

1. <graphic url="img/tealover.jpg"/> 2. <graphic url="/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg"/> 3. <graphic url="http://46.28.111.241:8081/exist/rest/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg"/>  4. <graphic url="url(img/tealover.jpg)"/> 5. <graphic url="url(/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg)"/> 6. <graphic url="url(http://46.28.111.241:8081/exist/rest/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg)"/>  7. <graphic url="url('img/tealover.jpg')"/> 8. <graphic url="url('/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg')"/> 9. <graphic url="url('http://46.28.111.241:8081/exist/rest/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg')"/> 

as expected, samples 3, 6 , 9 work but if have them in form of hardcoded links in source. if build links in xslt stylesheet, same in fo file there nothing in produced pdf.

equivalents produced in fo file:

1. <fo:external-graphic src="img/tealover.jpg"/> 2. <fo:external-graphic src="/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg"/> 3. <fo:external-graphic src="http://46.28.111.241:8081/exist/rest/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg"/>  4. <fo:external-graphic src="url(img/tealover.jpg)"/> 5. <fo:external-graphic src="url(/db/apps/karolinum-apps/data/2015080/img/tealover.jpg)"/> 6. <fo:external-graphic src="url(http://46.28.111.241:8081/exist/rest/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg)"/>  7. <fo:external-graphic src="url('img/tealover.jpg')"/> 8. <fo:external-graphic src="url('/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg')"/> 9. <fo:external-graphic src="url('http://46.28.111.241:8081/exist/rest/db/apps/karolinum-apps/data/mono/2015080/img/tealover.jpg')"/> 

when hard-code links source, in stylesheet works src="{@url}". when use short version of url everywhere (url="img/tealover.jpg"), in attribute stylesheet use

<xsl:value-of select="concat('http://46.28.111.241:8081/exist/rest', $imgpath, @url)"/> 

or directly in template

src="concat('http://46.28.111.241:8081/exist/rest', $imgpath, @url)" 

the $imgpath variable passed param application:

let $bookuri := base-uri($resource) let $imgpath := replace($bookuri, '[^/]*?$', '') 

with this, links 1, 4 , 7 should work, rest mess. can copy these links in exide , still work in browser.

when testing, looks fine. in pdf, there still no picture. guess there has tiny detail missing now.

got solution. unexpectedly, best thing let urls , focus on resolving of root paths. fop processor able resolve relative paths , works expected. in case, serve dynamic config file xslfo:render() function. important part is:

<hyphenation-base>{replace(request:get-url(), '/apps(.*?)$', '/rest')}/db/apps/karolinum-apps/modules/resources/hyph/</hyphenation-base> <hyphenation-pattern lang="cs" country="cz">cs</hyphenation-pattern> <base>{replace(request:get-url(), '/apps(.*?)$', '/rest') || replace(base-uri($doc), '[^/]*?$', '')}</base> <font-base>{replace(request:get-url(), '/apps(.*?)$', '/rest')}/db/apps/karolinum-apps/modules/resources/fonts/</font-base> 

now able store inside project , use relative paths in source files. hope solution survive next testing! if knew more elegant way how this, please, let me know (ok, first of put clumsy path operations variables).


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -