编辑:已解决-XML文档的路径不正确。我把这个令人难堪的问题留到一边,希望能对别人有所帮助。
环境:exist db 4.2.1、xquery 3.1、xslt 2.0
我正在用exist db中的许多模板构建一个网页,其中最后一个模板调用xsl转换来生成html片段。
当我在exist db外部测试它时,xsl转换工作。在这
XSLT fiddle
您有完整的XSLT文件和一个应该被转换的代表性的XML文档。它会毫无错误地生成预期的html。氧气也能毫无误差地产生这种转变。
然而,当我在exist db xquery中执行转换时,它发出执行信号……但它不会产生输出!
此项目的xar文件(包括所有模块和文件)可以在以下位置下载:
https://www.dropbox.com/s/gtg4lpv9jsh822e/deheresi-0.1.xar
这是xquery转换函数,它应该生成html片段:
declare function document:doc-xsl-docview($node as node(),
$model as map(*), $currentdoc as xs:string)
{
let $currentdocnode := doc(concat($globalvar:URIdb,$currentdoc))
let $xi := concat("xinclude-path=", $globalvar:URIdb)
let $xsltdoc := doc(concat($globalvar:URIstyles,
"ms609__testxsl-withmodes.xsl"))
let $xsltransform := transform:transform(
$currentdocnode,
$xsltdoc,
(<parameters>
<param name="paramPersonurl" value="{$globalvar:URLperson}"/>
<param name="paramPlaceurl" value="{$globalvar:URLplace}"/>
<param name="paramDocurl" value="{$globalvar:URLdoc}"/>
</parameters>),(),$xi)
return $xsltransform
};
这是HTML(在
document.html
)在模板中调用函数(最后一次模板调用)。其他的
doc-sidebar
模板执行得很好。
<div class="col-md-10 document-view">
输出为空div。
<div xmlns="http://www.w3.org/1999/xhtml" data-
template="templates:surround" data-template-
with="templates/site_wrapper.html" data-template-at="content">
<div class="col-md-12 document-title">
<h2>
<span class="en">Deposition: Arnald Donat</span>
<span class="fr">Déposition : Arnald Donat</span>
</h2>
</div>
<div class="col-sm-12">
<div class="col-md-2 sidebar">
<div data-template="document:doc-sidebar-sub1" data-template-currentdoc="ms609_0013.xml"/>
<div data-template="document:doc-sidebar-sub2" data-template-currentdoc="ms609_0013.xml"/>
<div data-template="document:doc-sidebar-sub3" data-template-currentdoc="ms609_0013.xml"/>
<div data-template="document:doc-sidebar-sub4" data-template-currentdoc="ms609_0013.xml"/>
</div>
<div class="col-md-10 document-view">
<div data-template="document:doc-xsl-docview" data-template-currentdoc="ms609_0013.xml"/>
</div>
</div>
</div>
作为测试的一部分,我做了以下工作:将预期的html片段硬编码到xsl文件中(
texthtmlonly.xsl
然后用相同的函数调用它。它成功地产生了输出。
此时,我看不出xsl转换不起作用的任何原因:
多谢提前。
注意:tei-xml文件(ms609_0013.xml)是临时硬编码的,用于在exist数据库中进行测试。
编辑:已解决-XML文档的路径不正确。我把这个令人难堪的问题留到一边,希望能对别人有所帮助。