eXist-db - 在自动文件创建中向 XML 文件添加序言?

eXist-db - adding prologue to XML file in automatic file creation?

在 eXist-db (4.7) 中,我有一个很长的 TEI-XML 文件,我从中创建了数千个独特的 TEI-XML 文件。我正在使用这样的函数:

let $list := doc(concat($globalvar:URIdata,"list_collections.xml"))
let $makefile := for $bib in $list//tei:bibl[@type="collection"]
                  let $newdoc := 
                            <listBibl xmlns="http://www.tei-c.org/ns/1.0" type="collection">{$bib}</listBibl>
             return xmldb:store($globalvar:URIdata, concat($bib//@xml:id,".xml"),$newdoc)
return $makefile

一切正常。

但是,我想在每个新文件的顶部添加一个序言,它指向我的自定义 TEI 模式:

<?xml-model href="../dictionaries/tei_thema.rng" 
            type="application/xml" 
            schematypens="http://relaxng.org/ns/structure/1.0"?>

有没有办法在上面的函数中做到这一点?如果没有,我是否可以创建一个辅助进程来将其插入到新文件的顶部?

非常感谢。

要添加 processing-instruction 只需将其添加为由它和您的内容组成的序列的第一个成员。

 let $doc = <demo></demo>
 let $newdoc := (<?xml-model href="../dictionaries/tei_thema.rng" 
        type="application/xml" 
        schematypens="http://relaxng.org/ns/structure/1.0"?>, $demo)
 return $newdoc

要显式构建新文档,请使用 document { } 例如你的情况

let $newdoc := document { <?xml-model href="../dictionaries/tei_thema.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>, <listBibl xmlns="http://www.tei-c.org/ns/1.0" type="collection">{$bib}</listBibl> }