我需要抓取一些图像,并将它们放入通过Apache生成的pdf中。在eXist之外,我没有任何问题。使用eXist,模板不能正常工作,输出中没有图像--可能是路径出现了问题。
“档案”的结构是:
project/data/file.xml
project/data/img/*pictures.jpg测试来源:
<figure>
<graphic url="img/tealover.jpg"/>
</figure>
<figure>
<graphic url="./img/tealover.jpg"/>
</figure>
<figure>
<graphic url="/db/apps/karolinum-apps/data/img/tealover.jpg"/>
</figure>模板:
<xsl:template match="tei:figure/tei:graphic">
<fo:block>
<fo:external-graphic src="{@url}" xsl:use-attribute-sets="images"/>
</fo:block>
<xsl:apply-templates/>
</xsl:template>问题在哪里?我是不是错过了一些eXist的设置?在ePub生产期间收集图像时,这是没有问题的。
更新
XSL-FO输出:
<fo:block>
<fo:external-graphic width="50%" content-height="100%" content-width="scale-to-fit" scaling="uniform" src="img/tealover.jpg"/>
</fo:block>
<fo:block>
<fo:external-graphic width="50%" content-height="100%" content-width="scale-to-fit" scaling="uniform" src="./img/tealover.jpg"/>
</fo:block>
<fo:block>
<fo:external-graphic width="50%" content-height="100%" content-width="scale-to-fit" scaling="uniform" src="/db/apps/karolinum-apps/data/img/tealover.jpg"/>
</fo:block>发布于 2016-01-26 10:26:46
这似乎是个妙招:
<xsl:template match="tei:figure/tei:graphic">
<fo:block>
<fo:external-graphic src="url('{resolve-uri(@url, base-uri(.))}')" xsl:use-attribute-sets="images"/>
</fo:block>
<xsl:apply-templates/>
</xsl:template>更新
有意思的!一开始它很有魅力。后来,我稍微重新安排了项目的结构(但文档附近的环境实际上是一样的),现在它不起作用了。它记录:
exerr:ERROR Exception while transforming node: Base URI {} is not an absolute URI [at line 11, column 19] In function:
fop:render-pdf(node()*) [12:5:/db/apps/karolinum-apps/modules/create-pdf.xqm]但问题显然是在这一行代码中。
即使我尝试<xsl:value-of select="resolve-uri(@url, base-uri(.))"/>,它也会抱怨
exerr:ERROR Exception while transforming node: Base URI {} is not an absolute URI [at line 16, column 9]目前还不能理解这么小的细节。
https://stackoverflow.com/questions/34947473
复制相似问题